Skip to content

[$250] Expense - 'Tag no longer valid' error not displayed #85214

Closed

Description

@jponikarchuk

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.37-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/folder/13176791/test-cases/41237176
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Windows 11, Chrome
App Component: Workspace Settings

Action Performed:

Preconditions:

  • The user has a workspace with 1 admin as a member
  • The workspace has tags enabled with at least 1 tag
  1. Go to https://staging.new.expensify.com/
  2. Sign in with the owner of the workspace
  3. Navigate to the workspace chat and create a manual expense with merchant and category
  4. Open the expense > More > Split
  5. Press CTRL/CMD + D and toggle on 'Force offline'
  6. Click Add split, open the new split, click Tag, select a tag, click Save, and save the split
  7. In an incognito tab, sign in as the admin of the workspace
  8. Click on Workspaces > {current workspace} > Tags, and delete the tag used in the split
  9. As the owner of the workspace, go online

Expected Result:

After going back online, the system should display an error message: 'Tag no longer valid'

Actual Result:

After going back online, a tag that is no longer valid shows no error message.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Video.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @allgandalf
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022032402994386771619
  • Upwork Job ID: 2032402994386771619
  • Last Price Increase: 2026-03-13

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Mar 13, 2026
  2. MelvinBot commented on Mar 13, 2026

    @MelvinBot
    Contributor

    Proposal

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

    When a user creates a split expense offline with a tag, and another admin deletes that tag from the workspace while the user is offline, no "Tag no longer valid" error is shown after the user goes back online. The tagOutOfPolicy violation never appears on the split expense's child transactions.

    What is the root cause of that problem?

    The split bill creation flow skips client-side violation computation entirely. When createSplitsAndOnyxData (in src/libs/actions/IOU/index.ts:7461) builds Onyx data for each split participant's child transaction, it calls buildOnyxDataForMoneyRequest without passing policyParams:

    buildOnyxDataForMoneyRequest({
        isOneOnOneSplit: true,
        // policyParams is NOT passed — defaults to {}
        optimisticParams: { ... },
        ...
    });
    

    Inside buildOnyxDataForMoneyRequest, policyParams defaults to {}, so policy is undefined. The guard at line 2484-2486 then triggers an early return:

    if (!policy || !isPaidGroupPolicy(policy) || ...) {
        return onyxData; // Skips ALL violation computation
    }

    This means ViolationsUtils.getViolationsOnyxData() is never called for split child transactions — no tagOutOfPolicy, categoryOutOfPolicy, or any other violations are computed.

    In contrast, regular (non-split) expenses go through getMoneyRequestInformation (line 3594-3603) which does pass policyParams: { policy, policyCategories, policyTagList }, so violations are computed optimistically at creation time.

    Additionally, there is no reactive client-side mechanism that recomputes violations when policy tags are updated via Pusher/Onyx sync. The pushTransactionViolationsOnyxData function in ReportUtils.ts only runs on the admin's device that performs the tag deletion — other users rely entirely on server-pushed violation updates.

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

    Pass policyParams (including policy, policyCategories, and policyTagList) through the split bill creation flow so that buildOnyxDataForMoneyRequest can compute violations for split child transactions:

    1. Update CreateSplitsAndOnyxDataParams (in src/libs/actions/IOU/index.ts:656) to accept an optional policyParams field of type BasePolicyParams.

    2. Update createSplitsAndOnyxData (line 7027) to accept and destructure the new policyParams field, and pass it to buildOnyxDataForMoneyRequest at line 7461.

    3. Update callers — splitBill, splitBillAndOpenReport, and their callers in IOURequestStepConfirmation.tsx — to pass policy, policyCategories, and policyTagList through (these are already available in the component via usePolicyForTransaction and usePolicyCategories hooks).

    4. Similarly update completeSplitBill in Split.ts which has the same gap.

    This aligns the split bill flow with how getMoneyRequestInformation already handles violation computation for regular expenses, ensuring tagOutOfPolicy (and other violations) are computed optimistically for split child transactions.

    What alternative solutions did you explore? (Optional)

    An alternative would be adding a reactive client-side mechanism (e.g., an Onyx subscriber on POLICY_TAGS) that recomputes violations when policy tag data changes. However, this would be more complex and less targeted — the simpler fix is to compute violations at split creation time, matching the existing pattern for regular expenses.


    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
    ExternalAdded to denote the issue can be worked on by a contributor
    on Mar 13, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Mar 13, 2026
  5. melvin-bot commented on Mar 13, 2026

    @melvin-bot

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

  6. changed the title [-]Expense - 'Tag no longer valid' error not displayed[/-] [+][$250] Expense - 'Tag no longer valid' error not displayed[/+] on Mar 13, 2026
  7. melvin-bot commented on Mar 13, 2026

    @melvin-bot
  8. MobileMage commented on Mar 13, 2026

    @MobileMage
    Contributor

    Proposal

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

    When a workspace tag is deleted by an admin while a transaction owner is offline, and the owner had tagged a split expense with that tag while offline, coming back online does not display the "Tag no longer valid" (tagOutOfPolicy) violation on the affected split transaction.

    What is the root cause of that problem?

    The deletePolicyTags action in src/libs/actions/Policy/Tag.ts calls pushTransactionViolationsOnyxData to recompute violations optimistically (when the delete is pending). This correctly adds a tagOutOfPolicy violation for transactions that use the deleted tag — but only on the admin's device where the delete action runs. The call to pushTransactionViolationsOnyxData produces entries only in optimisticData and failureData, never in successData.

    When the transaction owner is offline during the delete, their device never runs deletePolicyTags. When they reconnect, Onyx syncs the updated policy tags (deleted tags become null), but nothing recalculates violations for existing transactions. The split's queued request was built with an optimistic violation set computed when the tag was still valid (no tagOutOfPolicy). When that request succeeds, successData only clears pendingAction/pendingFields — there is no violation re-evaluation against the now-current policy tags.

    The gap is specifically at line 485 in Tag.ts:

    pushTransactionViolationsOnyxData(onyxData, policyData, {}, {}, policyTagsOptimisticData);

    pushTransactionViolationsOnyxData is called with the optimistic update (enabled: false) but there is no corresponding call to populate successData with violations that reflect the final state (null — tag fully removed). The owner's device, which receives the final state via Onyx sync, ends up with the deleted tag absent from policyTags but with no updated violations on their existing transactions.

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

    In deletePolicyTags in src/libs/actions/Policy/Tag.ts, add a second call to pushTransactionViolationsOnyxData that targets successData using the final tag update (the same null-valued entries that the current successData already writes for the policy tags). This way, when the success response is applied on any device — including one that was offline during the delete — the violations for all relevant transactions are recomputed reflecting the fully-removed tag.

    The pushTransactionViolationsOnyxData function already handles null tag updates correctly: it filters out null-valued tags from the merged tag list, causing any transaction that still references the deleted tag to have isTagInPolicy = false, which generates a tagOutOfPolicy violation as long as other enabled tags exist.

    };
    pushTransactionViolationsOnyxData(onyxData, policyData, {}, {}, policyTagsOptimisticData);
    const parameters = {
    policyID,
    tags: JSON.stringify(tagsToDelete),
    };
    API.write(WRITE_COMMANDS.DELETE_POLICY_TAGS, parameters, onyxData);

         pushTransactionViolationsOnyxData(onyxData, policyData, {}, {}, policyTagsOptimisticData);
    
    +    // Also push violation updates into successData, using the final state where deleted tags are null.
    +    // This ensures that devices which were offline during the delete (and receive the success state
    +    // via Onyx sync) also get their transaction violations recomputed against the updated tag list.
    +    const successOnyxData: OnyxData<typeof ONYXKEYS.COLLECTION.POLICY_TAGS | typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS> = {
    +        optimisticData: onyxData.successData,
    +        failureData: [],
    +    };
    +    const policyTagsSuccessData: Record<string, Record<string, Partial<OnyxValueWithOfflineFeedback<PolicyTag>> | null>> = {
    +        [policyTag.name]: {
    +            tags: tagsToDelete.reduce<Record<string, null>>((acc, tagName) => {
    +                acc[tagName] = null;
    +                return acc;
    +            }, {}),
    +        },
    +    };
    +    pushTransactionViolationsOnyxData(successOnyxData, policyData, {}, {}, policyTagsSuccessData);
    
         const parameters = {

    The trick here is constructing a temporary OnyxData-shaped object whose optimisticData is a reference to the real onyxData.successData array, so that pushTransactionViolationsOnyxData's internal onyxData.optimisticData?.push(...) calls append directly into the existing successData array. The failureData for this secondary call is intentionally empty — the failure path for the overall deletePolicyTags is already handled by the existing failureData which rolls back the tag list, which in turn rolls back violations via the first call's failureData.

    What alternative solutions did you explore? (Optional)

    An alternative would be to add an Onyx listener that watches for changes to POLICY_TAGS and re-evaluates violations for all policy transactions whenever tags are removed. This is more general but heavier — it would fire on every tag update regardless of whether any transaction is affected, and would require subscribing to both POLICY_TAGS and TRANSACTION collections simultaneously. The approach above is more surgical and consistent with how the rest of the codebase handles this pattern (e.g., setWorkspaceTagEnabled already uses pushTransactionViolationsOnyxData for its optimistic/failure paths).

  9. shivang-goliyan commented on Mar 13, 2026

    @shivang-goliyan
    Contributor

    Proposal

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

    When a user splits an existing expense (More > Split), selects a tag while offline, and the tag gets deleted by another admin before the user goes back online, no "Tag no longer valid" error appears. The tag violation is silently skipped for split child transactions.

    What is the root cause of that problem?

    The issue is a property name mismatch in updateSplitTransactions() at Split.ts:1165. The policyParams object is built using JavaScript shorthand notation:

    policyParams: {
        policy,
        policyCategories,
        policyTags,  // shorthand creates { policyTags: value }
    },
    

    But BasePolicyParams (defined at index.ts:497-503) expects the property to be called policyTagList, not policyTags. When getMoneyRequestInformation (index.ts:3274) destructures policyTagList from this object, it gets undefined. That undefined flows into buildOnyxDataForMoneyRequest where policyTagList ?? {} falls back to an empty object, and ViolationsUtils.getViolationsOnyxData() sees no tags to validate against — so tagOutOfPolicy is never added.

    This only affects the "split existing expense" path. Every other caller of buildOnyxDataForMoneyRequest maps the property correctly (e.g., getMoneyRequestInformation at index.ts:3599, SendInvoice.ts:701).

    The as MoneyRequestInformationParams type assertion at Split.ts:1203 hides this from TypeScript — without it, tsc would have flagged the mismatch at compile time.

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

    One-line fix at Split.ts:1165 — change policyTags, to policyTagList: policyTags,. This maps the local variable to the property name BasePolicyParams expects, so the full violation computation pipeline receives the actual policy tag data.

    This also fixes missingTag violations for splits (same dependency on policyTagList). Category violations are unaffected since policyCategories was already named correctly.

    What alternative solutions did you explore? (Optional)

    Renaming policyTagList to policyTags globally in BasePolicyParams would avoid this kind of mismatch, but it touches 20+ files that already use policyTagList correctly — not worth the churn for a one-line call-site fix. Separately, removing the as MoneyRequestInformationParams assertion at line 1203 would let TypeScript catch issues like this in the future, but that's a follow-up improvement, not the fix itself.

  10. FitseTLT commented on Mar 13, 2026

    @FitseTLT
    Contributor

    BE bug

  11. added
    InternalRequires API changes or must be handled by Expensify staff
    on Mar 15, 2026
  12. 30 remaining items

  13. allgandalf commented on Apr 7, 2026

    @allgandalf
    Contributor
  14. allgandalf commented on Apr 8, 2026

    @allgandalf
    Contributor

    PR in review

  15. allgandalf commented on Apr 9, 2026

    @allgandalf
    Contributor

    ^

  16. allgandalf commented on Apr 10, 2026

    @allgandalf
    Contributor

    ^

  17. melvin-bot commented on Apr 13, 2026

    @melvin-bot

    @allgandalf Whoops! This issue is 2 days overdue. Let's get this updated quick!

  18. allgandalf commented on Apr 15, 2026

    @allgandalf
    Contributor
  19. IuliiaHerets commented on Apr 15, 2026

    @IuliiaHerets

    v9.3.59-3
    Windows 11 / Chrome
    not repro

    tags.mp4
  20. allgandalf commented on Apr 15, 2026

    @allgandalf
    Contributor

    Closing this out, please comment if anything is remaining which i might have missed

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2InternalRequires API changes or must be handled by Expensify staffReviewingHas a PR in review

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions