Skip to content

fix: Task complete sound is heard after adding tag without Set up tag#81814

Open
paulnjs wants to merge 21 commits intoExpensify:mainfrom
paulnjs:paulnjs-fix/80294
Open

fix: Task complete sound is heard after adding tag without Set up tag#81814
paulnjs wants to merge 21 commits intoExpensify:mainfrom
paulnjs:paulnjs-fix/80294

Conversation

@paulnjs
Copy link
Copy Markdown
Contributor

@paulnjs paulnjs commented Feb 9, 2026

Explanation of Change

Fixed Issues

$#80294
PROPOSAL:#80294 (comment)

Tests

  1. Go to the app
  2. Create a new Gmail account.
  3. Click Skip on work email step.
  4. Select Something else and complete onboarding.
  5. Create a workspace.
  6. Delete the workspace.
  7. Create another workspace.
  8. Go to Categories.
  9. Edit the category by disabling a category.
  10. → No task complete sound in the background.
  11. Go to More features.
  12. Enable Tags.
  13. Go to Tags.
  14. Add a tag.
  15. Verify there is no task complete sound is heard in the background.
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  1. Go to the app
  2. Create a new Gmail account.
  3. Click Skip on work email step.
  4. Select Something else and complete onboarding.
  5. Create a workspace.
  6. Delete the workspace.
  7. Create another workspace.
  8. Go to Categories.
  9. Edit the category by disabling a category.
  10. → No task complete sound in the background.
  11. Go to More features.
  12. Enable Tags.
  13. Go to Tags.
  14. Add a tag.
  15. Verify there is no task complete sound is heard in the background.
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android.mp4
Android: mWeb Chrome
android-mweb.mp4
iOS: Native
ios.mp4
iOS: mWeb Safari
ios-mweb.mp4
MacOS: Chrome / Safari
web.mp4

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 9, 2026

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/libs/actions/Policy/Tag.ts 70.26% <100.00%> (+0.33%) ⬆️
...rc/pages/workspace/tags/WorkspaceCreateTagPage.tsx 0.00% <0.00%> (ø)
... and 18 files with indirect coverage changes

@paulnjs paulnjs marked this pull request as ready for review February 9, 2026 05:07
@paulnjs paulnjs requested review from a team as code owners February 9, 2026 05:07
@melvin-bot melvin-bot bot requested review from joekaufmanexpensify and situchan and removed request for a team February 9, 2026 05:07
@melvin-bot
Copy link
Copy Markdown

melvin-bot bot commented Feb 9, 2026

@situchan Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]


if (isTaskIncomplete(setupTagsTaskReport)) {
completeTask(setupTagsTaskReport, false, false, undefined);
// Complete the "Set up tags" onboarding task
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ CONSISTENCY-6 (docs)

The return value of getFinishOnboardingTaskOnyxData is not being used. This function returns OnyxData that must be merged into the onyxData object passed to the API call, otherwise the onboarding task completion will not work correctly.

Looking at the correct implementation in src/libs/actions/Policy/Category.ts (lines 89-99):

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you resolve this comment?

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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ CONSISTENCY-6 (docs)

Same issue here - the return value of getFinishOnboardingTaskOnyxData is not being used. The returned OnyxData must be merged into the onyxData object that was passed to API.write on line 211, otherwise the task completion state changes will not be persisted.


Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 9, 2026

Code Review Complete

I've reviewed PR #81814 and found 2 critical issues that need to be addressed:

Critical Issues

❌ CONSISTENCY-6 Violation (Return Values Not Used)

The code calls getFinishOnboardingTaskOnyxData twice but doesn't use the returned Onyx data. This means the onboarding tasks won't actually be completed, which defeats the purpose of this PR.

Location 1: src/libs/actions/Policy/Tag.ts:213-221
Location 2: src/libs/actions/Policy/Tag.ts:225-233

Required Fix

The function getFinishOnboardingTaskOnyxData returns OnyxData that must be merged into the API call's Onyx data structure. Here's the pattern you should follow:

// Get the onboarding task Onyx data
const setupTagsOnyxData = getFinishOnboardingTaskOnyxData(
    setupTagsTaskReport,
    setupTagsTaskParentReport,
    isSetupTagsTaskParentReportArchived ?? false,
    currentUserAccountID,
    setupTagsHasOutstandingChildTask ?? false,
    setupTagsParentReportAction,
);

// Merge it into the existing onyxData structure
if (setupTagsOnyxData) {
    onyxData.optimisticData.push(...(setupTagsOnyxData.optimisticData ?? []));
    onyxData.successData.push(...(setupTagsOnyxData.successData ?? []));
    onyxData.failureData.push(...(setupTagsOnyxData.failureData ?? []));
}

Apply this pattern for both the setupTagsTaskReport and setupCategoriesAndTagsTaskReport completion logic.

Why This Matters

Without using the return value, the Onyx store won't be updated to mark the tasks as complete, so:

  • The task completion sound will still play incorrectly
  • The onboarding tasks won't show as completed in the UI
  • This defeats the entire purpose of the PR

This review was performed by the code-inline-reviewer agent following Expensify's review guidelines.

Copy link
Copy Markdown
Contributor

@joekaufmanexpensify joekaufmanexpensify left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine for product

@situchan
Copy link
Copy Markdown
Contributor

@paulnjs please address bot reviews above

@situchan
Copy link
Copy Markdown
Contributor

And merge main

@paulnjs
Copy link
Copy Markdown
Contributor Author

paulnjs commented Feb 12, 2026

@situchan With comment from bot, getFinishOnboardingTaskOnyxData already handled completeTask inside it so we don't need to use any onyxData here

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 46131ec035

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

isSetupCategoriesAndTagsTaskParentReportArchived: false,
setupCategoriesAndTagsHasOutstandingChildTask: false,
setupCategoriesAndTagsParentReportAction: undefined,
currentUserAccountID: 0,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Badge Exercise onboarding completion path in new tag tests

The new createPolicyTag tests that claim to verify onboarding-task completion all pass currentUserAccountID: 0, but createPolicyTag now guards completion with if (setup*TaskReport && currentUserAccountID), so those test cases never execute getFinishOnboardingTaskOnyxData and cannot catch regressions in task completion behavior. Use a non-zero account ID (and assert task completion side effects) so these tests validate the path named in their descriptions.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thoughts?

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Failed to set up container
ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@situchan
Copy link
Copy Markdown
Contributor

@paulnjs bump ^. And conflicts

@paulnjs
Copy link
Copy Markdown
Contributor Author

paulnjs commented Mar 1, 2026

@situchan I updated. The test failed come from main

parentReportAction: setupCategoriesAndTagsParentReportAction,
} = useOnboardingTaskInformation(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES_AND_TAGS);

const createTag = useCallback(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove useCallback as this component is compatible with react compiler.

Image


if (isTaskIncomplete(setupTagsTaskReport)) {
completeTask(setupTagsTaskReport, false, false, undefined);
const isTaskForCurrentWorkspace = (taskReport: OnyxEntry<Report>) => !taskReport?.policyID || taskReport.policyID === policyID;
Copy link
Copy Markdown
Contributor

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.policyID is _FAKE_

Image

@situchan
Copy link
Copy Markdown
Contributor

situchan commented Mar 8, 2026

Actually I am not sure what the bug is in linked issue and what we're trying to fix. It seems this PR is just regressing the complete logic in concierge chat which works fine on production.

I don't even see tasks generated in #admins channel for first created workspace without deletion.
And task complete sound is always heard after disabling category, which is expected to complete task in concierge chat.

@paulnjs can you elaborate the bug what you fixed?

@paulnjs
Copy link
Copy Markdown
Contributor Author

paulnjs commented Mar 10, 2026

@situchan As mentioned in the proposal, this issue is that the task completion is still triggered after adding a tag in any workspace, even though the onboarding workspace has already been deleted.

To fix this, the PR ensures that before calling completeTask, we check whether the onboarding workspace still exists. If the onboarding workspace has been deleted, the task completion will not been triggered

@situchan
Copy link
Copy Markdown
Contributor

this issue is that the task completion is still triggered after adding a tag in any workspace

@paulnjs can you share video?

@situchan
Copy link
Copy Markdown
Contributor

You mean that concierge task should not be completed if triggered in non-onboarding workspace?

@paulnjs
Copy link
Copy Markdown
Contributor Author

paulnjs commented Mar 10, 2026

You mean that concierge task should not be completed if triggered in non-onboarding workspace?

No, I mean the concierge task shouldn't be completed if the onboarding workspace is deleted.

@paulnjs
Copy link
Copy Markdown
Contributor Author

paulnjs commented Mar 10, 2026

this issue is that the task completion is still triggered after adding a tag in any workspace

@paulnjs can you share video?

You can also check the video in the OP. At the 23rd second, the sound is triggered to announce that the task is completed, but it shouldn’t be, since the onboarding workspace was already deleted.

@situchan
Copy link
Copy Markdown
Contributor

Did you test category case? The category task is also completed when onboarding workspace is deleted.

@paulnjs
Copy link
Copy Markdown
Contributor Author

paulnjs commented Mar 10, 2026

@situchan Could you share a video? I tried creating a new category, but no task completion logic was triggered when onboarding workspace is deleted.

@situchan
Copy link
Copy Markdown
Contributor

@situchan Could you share a video? I tried creating a new category, but no task completion logic was triggered when onboarding workspace is deleted.

Screen.Recording.2026-03-10.at.4.00.45.PM.mov

@paulnjs
Copy link
Copy Markdown
Contributor Author

paulnjs commented Mar 16, 2026

@situchan In your video, the onboarding tasks are located in Concierge, not in the Admin room of the workspace. Because of that, if the workspace is deleted, the tasks can still be completed since they belong to Concierge rather than the workspace

@situchan
Copy link
Copy Markdown
Contributor

@situchan In your video, the onboarding tasks are located in Concierge, not in the Admin room of the workspace. Because of that, if the workspace is deleted, the tasks can still be completed since they belong to Concierge rather than the workspace

Do you have repro step of onboarding tasks being located in Admin room?

@paulnjs
Copy link
Copy Markdown
Contributor Author

paulnjs commented Mar 16, 2026

@situchan You can create new account without "+" character

@situchan
Copy link
Copy Markdown
Contributor

Please merge main

@MelvinBot
Copy link
Copy Markdown
Contributor

Code Review

PR Status: All CI checks pass. The approach aligns with the approved proposal.

Summary

This PR fixes the bug where a "task complete" sound plays after adding a tag in a workspace that doesn't have the corresponding onboarding task, specifically when the original onboarding workspace was deleted. The fix replaces direct completeTask() calls with getFinishOnboardingTaskOnyxData() (which validates eligibility before completing) and adds workspace-scoping via isTaskForCurrentWorkspace.

Previous Bot Review (Addressed)

The earlier automated review flagged that getFinishOnboardingTaskOnyxData's return value is not used. This is a non-issue. getFinishOnboardingTaskOnyxData internally calls completeTask() which fires API.write(WRITE_COMMANDS.COMPLETE_TASK) with its own optimistic data — so the return value is already applied. Discarding the return value is the correct pattern here, and matches completeTestDriveTask at Task.ts:1351-1362 which also discards it.

What Looks Good

  1. Core fix is correct — Using getFinishOnboardingTaskOnyxData adds canActionTask validation before completing the task, preventing stale task completion.
  2. Workspace scopingisTaskForCurrentWorkspace at Tag.ts:215 correctly allows tasks without a policyID (Concierge-based tasks) while blocking tasks that belong to a different workspace.
  3. IntroSelectedTask type update — Adding 'setupTags' is necessary and matches CONST.ONBOARDING_TASK_TYPE.SETUP_TAGS at CONST/index.ts:8263.
  4. Tests are comprehensive — Covers both task types, the "no custom categories" skip case, and the new cross-workspace guard.

Minor Notes (Non-blocking)

  1. useCallback removalvalidate and createTag in WorkspaceCreateTagPage.tsx were previously wrapped in useCallback and are now plain functions. This creates new function references on every render. It's unlikely to cause noticeable issues in this form context, but is a slight deviation from the original code's memoization pattern.

  2. Naming ambiguitygetFinishOnboardingTaskOnyxData is misleadingly named since it fires an API call as a side effect. This is a pre-existing issue and not introduced by this PR. Worth a future rename to something like finishOnboardingTask.

Verdict

The approach is sound and follows the approved proposal. The isTaskForCurrentWorkspace guard correctly solves the reported bug. All checks pass, tests cover the key scenarios. LGTM pending merge with main as requested by the reviewer.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Failed to set up container
ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@situchan
Copy link
Copy Markdown
Contributor

@paulnjs remove this code:

const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const setupTagsTaskReportID = introSelected?.setupTags;
const [setupTagsTaskReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${setupTagsTaskReportID}`);
const {taskReport: setupCategoriesAndTagsTaskReport} = useOnboardingTaskInformation(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES_AND_TAGS);

Then use taskReport from useOnboardingTaskInformation hook

    const {
+       taskReport: setupTagsTaskReport,
        taskParentReport: setupTagsTaskParentReport,
        isOnboardingTaskParentReportArchived: isSetupTagsTaskParentReportArchived,
        hasOutstandingChildTask: setupTagsHasOutstandingChildTask,
        parentReportAction: setupTagsParentReportAction,
    } = useOnboardingTaskInformation(CONST.ONBOARDING_TASK_TYPE.SETUP_TAGS);

    const {
+       taskReport: setupCategoriesAndTagsTaskReport,
        taskParentReport: setupCategoriesAndTagsTaskParentReport,
        isOnboardingTaskParentReportArchived: isSetupCategoriesAndTagsTaskParentReportArchived,
        hasOutstandingChildTask: setupCategoriesAndTagsHasOutstandingChildTask,
        parentReportAction: setupCategoriesAndTagsParentReportAction,
    } = useOnboardingTaskInformation(CONST.ONBOARDING_TASK_TYPE.SETUP_CATEGORIES_AND_TAGS);

@melvin-bot melvin-bot bot requested a review from blimpich March 23, 2026 15:07
@situchan
Copy link
Copy Markdown
Contributor

There's lint error

@paulnjs
Copy link
Copy Markdown
Contributor Author

paulnjs commented Mar 23, 2026

The lint error is fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants