-
Notifications
You must be signed in to change notification settings - Fork 3.9k
The category onboarding task was not marked as complete after deactivating a category #60608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
srikarparsi
merged 5 commits into
Expensify:main
from
thelullabyy:fix/59213-category-onboarding-task-was-not-marked
Apr 25, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
011e072
fix: category onboarding task not marked
thelullabyy 141b954
refactor
thelullabyy 126d9fa
refactor code
thelullabyy bfa1168
refactor code
thelullabyy 917de05
Merge branch 'main' into fix/59213-category-onboarding-task-was-not-m…
thelullabyy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ import type * as OnyxTypes from '@src/types/onyx'; | |
| import type {Icon} from '@src/types/onyx/OnyxCommon'; | ||
| import type {ReportActions} from '@src/types/onyx/ReportAction'; | ||
| import type ReportAction from '@src/types/onyx/ReportAction'; | ||
| import type {OnyxData} from '@src/types/onyx/Request'; | ||
| import {isEmptyObject} from '@src/types/utils/EmptyObject'; | ||
| import {getMostRecentReportID, navigateToConciergeChatAndDeleteReport, notifyNewAction} from './Report'; | ||
|
|
||
|
|
@@ -87,6 +88,12 @@ Onyx.connect({ | |
| }, | ||
| }); | ||
|
|
||
| let introSelected: OnyxEntry<OnyxTypes.IntroSelected> = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.NVP_INTRO_SELECTED, | ||
| callback: (val) => (introSelected = val), | ||
| }); | ||
|
|
||
| /** | ||
| * Clears out the task info from the store | ||
| */ | ||
|
|
@@ -370,11 +377,11 @@ function getOutstandingChildTask(taskReport: OnyxEntry<OnyxTypes.Report>) { | |
| /** | ||
| * Complete a task | ||
| */ | ||
| function completeTask(taskReport: OnyxEntry<OnyxTypes.Report>, reportIDFromAction?: string) { | ||
| function completeTask(taskReport: OnyxEntry<OnyxTypes.Report>, reportIDFromAction?: string): OnyxData { | ||
| const taskReportID = taskReport?.reportID ?? reportIDFromAction; | ||
|
|
||
| if (!taskReportID) { | ||
| return; | ||
| return {}; | ||
| } | ||
|
|
||
| const message = `marked as complete`; | ||
|
|
@@ -455,6 +462,7 @@ function completeTask(taskReport: OnyxEntry<OnyxTypes.Report>, reportIDFromActio | |
|
|
||
| playSound(SOUNDS.SUCCESS); | ||
| API.write(WRITE_COMMANDS.COMPLETE_TASK, parameters, {optimisticData, successData, failureData}); | ||
| return {optimisticData, successData, failureData}; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1266,6 +1274,19 @@ function clearTaskErrors(reportID: string | undefined) { | |
| }); | ||
| } | ||
|
|
||
| function getFinishOnboardingTaskOnyxData(taskName: keyof OnyxTypes.IntroSelected): OnyxData { | ||
| const taskReportID = introSelected?.[taskName]; | ||
| if (taskReportID) { | ||
| const taskReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`]; | ||
| if (taskReport) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also check if the taskReport is not archived before marking it as completed. |
||
| if (taskReport.stateNum !== CONST.REPORT.STATE_NUM.APPROVED || taskReport.statusNum !== CONST.REPORT.STATUS_NUM.APPROVED) { | ||
| return completeTask(taskReport); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return {}; | ||
| } | ||
| function completeTestDriveTask() { | ||
| const onboardingReport = ReportUtils.getChatUsedForOnboarding(); | ||
| if (!onboardingReport) { | ||
|
|
@@ -1312,5 +1333,6 @@ export { | |
| setNewOptimisticAssignee, | ||
| getNavigationUrlOnTaskDelete, | ||
| canActionTask, | ||
| getFinishOnboardingTaskOnyxData, | ||
| completeTestDriveTask, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thelullabyy Would it be possible to make this into a pure function? The way it is now, it is accessing data from two globals:
In my PR #60869 I am having to add one more due to the way this function was initially written:
This is not ideal because it means this function is making a lot of assumptions about data existing out in the global scope that it doesn't have very much control over.
Ideally, this method would accept the
taskReportas an argument, and then no globals would need to be accessed.Is this something that you can help me clean up?