-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix: Task complete sound is heard after adding tag without Set up tag #81814
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
Changes from 19 commits
0f0d475
57c4216
33d1e7f
46131ec
0d0212b
7f10f11
2b555f2
0c7b3c3
cd93e0b
b2f8f00
4d579fd
2b99b76
028e557
8b1794f
4bf7c63
980cbe7
63dfead
442495b
e5b5172
df91801
9a30645
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,20 +29,30 @@ import {goBackWhenEnableFeature} from '@libs/PolicyUtils'; | |
| import {pushTransactionViolationsOnyxData} from '@libs/ReportUtils'; | ||
| import {getTagArrayFromName} from '@libs/TransactionUtils'; | ||
| import type {PolicyTagList} from '@pages/workspace/tags/types'; | ||
| import {completeTask} from '@userActions/Task'; | ||
| import {getFinishOnboardingTaskOnyxData} from '@userActions/Task'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type {ImportedSpreadsheet, Policy, PolicyTag, PolicyTagLists, PolicyTags, RecentlyUsedTags, Report} from '@src/types/onyx'; | ||
| import type {ImportedSpreadsheet, Policy, PolicyTag, PolicyTagLists, PolicyTags, RecentlyUsedTags, Report, ReportAction} from '@src/types/onyx'; | ||
| import type {OnyxValueWithOfflineFeedback} from '@src/types/onyx/OnyxCommon'; | ||
| import type {ApprovalRule} from '@src/types/onyx/Policy'; | ||
| import type {OnyxData} from '@src/types/onyx/Request'; | ||
|
|
||
| /** | ||
| * Checks if a task report is incomplete (not approved) | ||
| */ | ||
| function isTaskIncomplete(taskReport: OnyxEntry<Report>): boolean { | ||
| return !!taskReport && (taskReport.stateNum !== CONST.REPORT.STATE_NUM.APPROVED || taskReport.statusNum !== CONST.REPORT.STATUS_NUM.APPROVED); | ||
| } | ||
| type CreatePolicyTagParams = { | ||
| policyData: PolicyData; | ||
| tagName: string; | ||
| setupTagsTaskReport: OnyxEntry<Report>; | ||
| setupTagsTaskParentReport: OnyxEntry<Report>; | ||
| isSetupTagsTaskParentReportArchived: boolean; | ||
| setupTagsHasOutstandingChildTask: boolean; | ||
| setupTagsParentReportAction: OnyxEntry<ReportAction>; | ||
| setupCategoriesAndTagsTaskReport: OnyxEntry<Report>; | ||
| setupCategoriesAndTagsTaskParentReport: OnyxEntry<Report>; | ||
| isSetupCategoriesAndTagsTaskParentReportArchived: boolean; | ||
| setupCategoriesAndTagsHasOutstandingChildTask: boolean; | ||
| setupCategoriesAndTagsParentReportAction: OnyxEntry<ReportAction>; | ||
| currentUserAccountID: number; | ||
| policyHasCustomCategories: boolean; | ||
| }; | ||
|
|
||
| function openPolicyTagsPage(policyID: string) { | ||
| if (!policyID) { | ||
|
|
@@ -120,13 +130,22 @@ function updateImportSpreadsheetData(tagsLength: number): OnyxData<typeof ONYXKE | |
| return onyxData; | ||
| } | ||
|
|
||
| function createPolicyTag( | ||
| policyData: PolicyData, | ||
| tagName: string, | ||
| setupTagsTaskReport?: OnyxEntry<Report>, | ||
| setupCategoriesAndTagsTaskReport?: OnyxEntry<Report>, | ||
| policyHasCustomCategories?: boolean, | ||
| ) { | ||
| function createPolicyTag({ | ||
| policyData, | ||
| tagName, | ||
| setupTagsTaskReport, | ||
| setupTagsTaskParentReport, | ||
| isSetupTagsTaskParentReportArchived, | ||
| setupTagsHasOutstandingChildTask, | ||
| setupTagsParentReportAction, | ||
| setupCategoriesAndTagsTaskReport, | ||
| setupCategoriesAndTagsTaskParentReport, | ||
| isSetupCategoriesAndTagsTaskParentReportArchived, | ||
| setupCategoriesAndTagsHasOutstandingChildTask, | ||
| setupCategoriesAndTagsParentReportAction, | ||
| currentUserAccountID, | ||
| policyHasCustomCategories, | ||
| }: CreatePolicyTagParams) { | ||
| const {policy, tags: policyTags} = policyData; | ||
| const policyID = policy?.id; | ||
| const policyTag = PolicyUtils.getTagLists(policyTags)?.at(0) ?? ({} as PolicyTagList); | ||
|
|
@@ -194,12 +213,30 @@ function createPolicyTag( | |
|
|
||
| API.write(WRITE_COMMANDS.CREATE_POLICY_TAG, parameters, onyxData); | ||
|
|
||
| if (isTaskIncomplete(setupTagsTaskReport)) { | ||
| completeTask(setupTagsTaskReport, false, false, undefined); | ||
| const isTaskForCurrentWorkspace = (taskReport: OnyxEntry<Report>) => !taskReport?.policyID || taskReport.policyID === policyID; | ||
|
|
||
| // Complete the "Set up tags" onboarding task | ||
|
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. ❌ CONSISTENCY-6 (docs)The return value of Looking at the correct implementation in const finishOnboardingTaskData = getFinishOnboardingTaskOnyxData(
setupCategoryTaskReport,
setupCategoryTaskParentReport,
isSetupCategoriesTaskParentReportArchived,
currentUserAccountID,
hasOutstandingChildTask,
parentReportAction,
);
onyxData.optimisticData?.push(...(finishOnboardingTaskData.optimisticData ?? []));
onyxData.successData?.push(...(finishOnboardingTaskData.successData ?? []));
onyxData.failureData?.push(...(finishOnboardingTaskData.failureData ?? []));The same pattern should be applied here for both task completions. Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
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. Can you resolve this comment? |
||
| if (setupTagsTaskReport && currentUserAccountID && isTaskForCurrentWorkspace(setupTagsTaskReport)) { | ||
| getFinishOnboardingTaskOnyxData( | ||
| setupTagsTaskReport, | ||
| setupTagsTaskParentReport, | ||
| isSetupTagsTaskParentReportArchived ?? false, | ||
| currentUserAccountID, | ||
| setupTagsHasOutstandingChildTask ?? false, | ||
| setupTagsParentReportAction, | ||
| ); | ||
| } | ||
|
|
||
| if (isTaskIncomplete(setupCategoriesAndTagsTaskReport) && policyHasCustomCategories) { | ||
| completeTask(setupCategoriesAndTagsTaskReport, false, false, undefined); | ||
| // Complete the combined "Set up categories and tags" task only if categories already exist | ||
| if (setupCategoriesAndTagsTaskReport && policyHasCustomCategories && currentUserAccountID && isTaskForCurrentWorkspace(setupCategoriesAndTagsTaskReport)) { | ||
| getFinishOnboardingTaskOnyxData( | ||
| setupCategoriesAndTagsTaskReport, | ||
| setupCategoriesAndTagsTaskParentReport, | ||
| isSetupCategoriesAndTagsTaskParentReportArchived ?? false, | ||
| currentUserAccountID, | ||
| setupCategoriesAndTagsHasOutstandingChildTask ?? false, | ||
| setupCategoriesAndTagsParentReportAction, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
This always returns false because
taskReport.policyIDis_FAKE_