Skip to content

[$250] Onboarding- Task "Set up categories and tags" isn't auto-checked after completed #87482

Closed

Description

@nlemma

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.3.55-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/TR-17114/folder/13176677/41237662/1317002015
Email or phone of affected tester (no customers): lekima20+642404@gmail.com
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Win 11/Chrome
App Component: Other

Action Performed:

  1. Open https://staging.new.expensify.com
  2. Create a new user with select option "Manage my team's expenses" and complete flow
  3. Navigate to Concierge chat
  4. Click on 'categories" at the task 'Set up categories and tags'
  5. Add a category
  6. Click on More features and enable Tags
  7. Click on Tags tab and add some tags
  8. Navigate to Concierge chat
  9. Refresh page
  10. Click on the task 'Set up categories and tags'

Expected Result:

The task 'Set up categories and tags' should get auto-checked

Actual Result:

The task 'Set up categories and tags’ isn't auto-checked

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7125664_1775722351452.Recording__1959.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022042198222552145991
  • Upwork Job ID: 2042198222552145991
  • Last Price Increase: 2026-04-16
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    Daily
    Bug
    on Apr 9, 2026
  2. MelvinBot commented on Apr 9, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The combined "Set up categories and tags" onboarding task has a cross-dependency for auto-completion that is asymmetric:

    • Category creation path (Category.ts:900): completes the combined task if policyHasTags is true — this checks for ANY tags via hasTags() at PolicyUtils.ts:672
    • Tag creation path (Tag.ts:231): completes the combined task if policyHasCustomCategories is true — this uses hasCustomCategories() at PolicyUtils.ts:680 which only counts categories whose names are not in the 19 default categories list (CONST.POLICY.DEFAULT_CATEGORIES)

    In the normal user flow (categories first → tags second), auto-completion depends on the tag creation path. Since new workspaces come pre-populated with only default categories, if the user enables/toggles a default category or adds a category that happens to match a default name, hasCustomCategories returns false and the combined task never auto-completes.

    The category-side check (policyHasTags) is permissive — any tag counts. The tag-side check (policyHasCustomCategories) is overly restrictive — only non-default-named categories count. This asymmetry is the bug.

    What changes do you think we should make in order to solve the problem?

    Replace the policyHasCustomCategories condition at Tag.ts:231 with a broader check that mirrors the permissiveness of the category-side check.

    Specifically, change hasCustomCategories to hasEnabledCategories (or similar) that returns true when the user has any enabled categories — including default ones. Since the user was directed from the task to set up categories and has navigated there, having enabled categories confirms they've "set up categories."

    Alternatively, since setWorkspaceCategoryEnabled at Category.ts:460 already completes the combined task when policyHasTags is true (without checking for custom names), the simplest consistent fix is to use the same permissive check on the tag side — just verify that categories exist on the policy, not that they are custom-named.

    What alternative solutions did you explore? (Optional)

    • Remove the cross-check entirely: auto-complete the combined task on either a category or tag action, without requiring the other to exist. Rejected because the task is "Set up categories AND tags" — both should be configured.
    • Track user visits: mark the task as "categories set up" when the user visits the categories page, then auto-complete when tags are also created. Rejected as over-engineered — the existing mechanism just needs the condition relaxed.
    Investigation details

    Key code paths:

    • Combined task definition: OnboardingFlow.ts:266-272 (autoCompleted: false)
    • Task filtering: ReportUtils.ts:11835-11841 — combined task only created when userReportedIntegration is truthy
    • Category-side auto-check: Category.ts:899-910 — uses policyHasTags (permissive)
    • Tag-side auto-check: Tag.ts:230-240 — uses policyHasCustomCategories (restrictive)
    • hasCustomCategories: PolicyUtils.ts:680-688 — filters against CONST.POLICY.DEFAULT_CATEGORIES (19 names: Advertising, Benefits, Car, Equipment, Fees, Home Office, Insurance, Interest, Labor, Maintenance, Materials, Meals and Entertainment, Office Supplies, Other, Professional Services, Rent, Taxes, Travel, Utilities)
    • hasTags: PolicyUtils.ts:672-674 — checks for ANY tags in any tag list
    • Task completion mechanism: Task.ts:1429-1446 → completeTask at Task.ts:502-526

    Data flow for user's repro steps:

    1. User creates workspace → default categories pre-populated
    2. User adds a category → createPolicyCategory fires → policyHasTags is false → combined task NOT completed
    3. User enables Tags → feature toggle only, no tags created
    4. User creates a tag → createPolicyTag fires → policyHasCustomCategories checked → returns false if category name matches a default → combined task NOT completed

    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  3. added
    External
    on Apr 9, 2026
  4. added
    Help Wanted
    on Apr 9, 2026
  5. melvin-bot commented on Apr 9, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @DylanDylann (External)

  6. changed the title [-]Onboarding- Task "Set up categories and tags" isn't auto-checked after completed[/-] [+][$250] Onboarding- Task "Set up categories and tags" isn't auto-checked after completed[/+] on Apr 9, 2026
  7. melvin-bot commented on Apr 9, 2026

    @melvin-bot
  8. yuvrajangadsingh commented on Apr 9, 2026

    @yuvrajangadsingh
    Contributor

    Proposal (updated to address @nkdengineer's flaw)

    Please re-state the problem that we are trying to solve in this issue.

    The onboarding task "Set up categories and tags" never auto-completes after the user adds categories and tags following the task instructions.

    What is the root cause of that problem?

    PR #81814 added an isTaskForCurrentWorkspace gate in Tag.ts that checks !taskReport?.policyID || taskReport.policyID === policyID. When shouldPostTasksInAdminsRoom is false (emails with +, or non-MANAGE_TEAM flows), onboarding tasks are created in the Concierge chat. buildOptimisticTaskReport at ReportUtils.ts:8631 receives targetChatPolicyID from the Concierge chat, which resolves to _FAKE_ or empty string. So the check taskReport.policyID === policyID fails because _FAKE_ !== actualWorkspacePolicyID, and the task never completes.

    I traced DylanDylann's suggestion of fixing policyID at the source. nkdengineer's evidence shows that changing the task report's policyID would break the data model: child reports inherit parent policyID, and overriding it causes UI regressions ("Go to workspace" appearing in task detail).

    What changes do you think we should make in order to solve the problem?

    The Concierge fallback must be workspace-specific, not just "came from Concierge". A naive isConciergeChatReport(taskParentReport) check returns true for ANY tag creation in any workspace, which incorrectly completes the onboarding task for unrelated workspaces.

    The reliable signal: the task description embeds the workspace URL (e.g. [create a tag](https://staging.new.expensify.com/g/settings/workspaces/{policyID}/tags/new)). Parse it to identify the specific onboarding workspace.

    const ONBOARDING_POLICY_URL_REGEX = /\/settings\/workspaces\/([^\/]+)\//;
    
    const getOnboardingPolicyIDFromTask = (taskReport: OnyxEntry<Report>): string | undefined => {
        const match = taskReport?.description?.match(ONBOARDING_POLICY_URL_REGEX);
        return match?.[1];
    };
    
    const isTaskForCurrentWorkspace = (taskReport: OnyxEntry<Report>): boolean => {
        if (!taskReport?.policyID || taskReport.policyID === policyID) {
            return true;
        }
        if (taskReport.policyID === CONST.POLICY.ID_FAKE) {
            return getOnboardingPolicyIDFromTask(taskReport) === policyID;
        }
        return false;
    };

    This fixes the bug nkdengineer identified: the Concierge-task case now compares the embedded workspace policyID to the current workspace, not just "is this in Concierge".

    Long-term fix (separate PR): Add onboardingPolicyID field to the IntroSelected NVP. Set it during prepareOnboardingOnyxData when tasks are created. Read it during completion checks. This avoids parsing description text entirely and survives any future task description format changes.

    Apply the same isTaskForCurrentWorkspace pattern to:

    • setupTagsTaskReport check at Tag.ts:197
    • setupCategoriesAndTagsTaskReport check at Tag.ts:201
    • appendSetupCategoriesOnboardingData in Category.ts (currently has no policyID gate, will need symmetric fix to avoid the same bug going forward)

    What alternative solutions did you explore? (Optional)

    1. Parent-report context only (my earlier proposal, also nabi-ebrahimi's): rejected by nkdengineer because isConciergeChatReport(parent) is workspace-agnostic and triggers for tags created in unrelated workspaces.
    2. Fix policyID at source (DylanDylann's direction): breaks parent-child data model, causes UI regressions per nkdengineer's screenshots.
    3. Revert PR fix: Task complete sound is heard after adding tag without Set up tag #81814: removes the gate entirely, but that PR fixed real cross-workspace task completion bugs.
  9. nkdengineer commented on Apr 9, 2026

    @nkdengineer
    Contributor

    Proposal

    What is the root cause of that problem?

    The Set up categories and tags task is completed only if the task report is related to the current workspace.

    if (setupCategoriesAndTagsTaskReport && policyHasCustomCategories && currentUserAccountID && isTaskForCurrentWorkspace(setupCategoriesAndTagsTaskReport)) {
    getFinishOnboardingTaskOnyxData(
    setupCategoriesAndTagsTaskReport,
    setupCategoriesAndTagsTaskParentReport,
    isSetupCategoriesAndTagsTaskParentReportArchived ?? false,
    currentUserAccountID,

    When the user has + in the email, the onboarding task is created in the concierge chat, report?.policyID is _FAKE_ which causes isTaskForCurrentWorkspace to fail. Then the task is not completed.

    const isTaskForCurrentWorkspace = (taskReport: OnyxEntry<Report>) => !taskReport?.policyID || taskReport.policyID === policyID;

    What changes do you think we should make in order to solve the problem?

    1. Update the backend with CompleteGuidedSetup API to store the policyID from the parameter to an onyx key. We can store this as a field of nvp_onboarding or nvp_introSelected or store it in a new key.

    2. Frontend change:

    • In prepareOnboardingOnyxData, store the onboardingPolicyID in optimistic data with the key we defined to store in the backend at point 1

    • Get the onboardingPolicyID from the key above, pass it from the component to isTaskForCurrentWorkspace and use this to compare with policyID instead of using taskReport?.policyID

    const isTaskForCurrentWorkspace = (taskReport: OnyxEntry<Report>) => !taskReport?.policyID || taskReport.policyID === policyID;

    What alternative solutions did you explore? (Optional)

    We can remove isTaskForCurrentWorkspace as we don't use this when completing the task here

    const isTaskForCurrentWorkspace = (taskReport: OnyxEntry<Report>) => !taskReport?.policyID || taskReport.policyID === policyID;

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  10. github-actions commented on Apr 9, 2026

    @github-actions
    Contributor

    ⚠️ @nkdengineer Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).

  11. Yatin-Bhatti commented on Apr 9, 2026

    @Yatin-Bhatti

    What is the root cause of that problem?

    The failure to auto-complete the task is caused by Requirement Asymmetry and UI-Logic Coupling.
    Asymmetric Logic: The "Set up categories and tags" task has two triggers. The category-creation trigger is permissive (any tag counts), but the tag-creation trigger is restrictive. Specifically, Tag.ts uses hasCustomCategories, which explicitly ignores the 19 default categories. If a user fulfills the onboarding requirement by enabling a default category and then adding a tag, the system fails to transition the task to "complete" because it is strictly looking for non-default category names.
    State Desynchronization: The logic currently depends on boolean flags (like policyHasCustomCategories) being passed as props from the UI layer to the Action layer. If the user has an email with a + sign or is in a specific onboarding state where policyID is masked as FAKE, the UI-level checks can fail to resolve the correct workspace context, preventing the completion signal from being dispatched to the server even if the data is valid.

    What changes do you think we should make in order to solve the problem?

    I propose a Policy-State Evaluation approach that moves the completion authority away from UI props and into a centralized utility:

    Centralize Setup Verification: In PolicyUtils.ts, I will create a unified helper isCategoriesAndTagsSetup(policyID). This function will determine setup completion by checking for the existence of any enabled category (including defaults) and any active tag. This ensures a "Single Source of Truth" for this specific onboarding milestone.

    Action-Layer Autonomy: I will refactor createPolicyTag in Tag.ts and the category update functions in Category.ts to call this new helper directly using the policyID. This removes the need to pass policyHasCustomCategories or policyHasTags as arguments from the React components, reducing the risk of stale data or prop-drilling errors.

    Relax Category Constraints: I will update the completion check in Tag.ts to replace hasCustomCategories with a check that validates if the user has any categories configured. Toggling a default category is a valid "setup" action and should satisfy the onboarding requirement.

    Contextual Policy ID Resolution: I will update the isTaskForCurrentWorkspace check to handle the FAKE policyID scenario. If the direct policyID check fails, the logic will attempt to resolve the context via the parentReportID to ensure users on the guided onboarding path aren't locked out of task completion.

    What alternative solutions did you explore? (Optional)

    I considered simply removing the default category filter from hasCustomCategories. However, that function might be used elsewhere in the app where "Custom" actually means "Non-Default." By creating a dedicated isCategoriesAndTagsSetup helper, we fix the onboarding bug without creating side effects for other features that might need to distinguish between default and custom categories. I also considered auto-completing the task upon the first navigation to the categories page, but rejected it because it doesn't guarantee the user actually performed the required setup.

  12. melvin-bot commented on Apr 9, 2026

    @melvin-bot
  13. 76 remaining items

  14. nkdengineer commented on Jun 1, 2026

    @nkdengineer
    Contributor

    @roryabraham When we reset cache, the onboarding tasks are cleared. Looks like the backend doesn't create the tasks in the onboarding flow now for all purposes.

    Screen.Recording.2026-06-01.at.13.21.16.mov
  15. nkdengineer commented on Jun 9, 2026

    @nkdengineer
    Contributor

    @DylanDylann @roryabraham Any thoughts on my comment above?

  16. DylanDylann commented on Jun 9, 2026

    @DylanDylann
    Contributor

    Nice catch! Clearing the cache also removed the onboarding task on my end. Are you still able to reproduce this issue?

  17. nkdengineer commented on Jun 22, 2026

    @nkdengineer
    Contributor

    @DylanDylann I can't reproduce now. The manage team purpose doesn't create onboarding task anymore.

  18. DylanDylann commented on Jun 22, 2026

    @DylanDylann
    Contributor

    @nkdengineer Could you verify this for other onboarding purposes? If setting the category and tags no longer appear on the onboarding task, I agree that this issue should be closed.

  19. nkdengineer commented on Jun 29, 2026

    @nkdengineer
    Contributor

    @DylanDylann, we only have the category tag. No set up categories and tags anymore.

    Image
  20. DylanDylann commented on Jun 30, 2026

    @DylanDylann
    Contributor

    @nkdengineer I just checked again and agree with you that this bug no longer reproduces. Please close the PR

  21. nkdengineer commented on Jul 7, 2026

    @nkdengineer
    Contributor

    @roryabraham, the issue is no longer reproducible. Can you please assign someone to handle payment here? Thanks.

  22. roryabraham commented on Jul 8, 2026

    @roryabraham
    Contributor

    @mallenexpensify Default payments of $250 to @nkdengineer and @DylanDylann payable immediately

  23. mallenexpensify commented on Jul 9, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @nkdengineer due $250 via NewDot
    Contributor+: @DylanDylann due $250 via NewDot

  24. twisterdotcom commented on Jul 15, 2026

    @twisterdotcom
    Contributor

    $250 approved for @nkdengineer in Report ID: R00JRhw1xXfR.

    Zapier Logs Run ID: 00040eee-8ab5-a671-b0fb-f072391cad14

    SO: https://stackoverflowteams.com/c/expensify/questions/7582

  25. quinthar commented on Jul 31, 2026

    @quinthar
    Contributor

    Approved $250 to @DylanDylann

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

Metadata

Metadata

Labels

BugExternalReviewingWeekly

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions