Skip to content

"no longer valid" appears on 1st level tag when 2nd level tag is applied with expense rule #82464

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: 9.3.19-0
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #81454
Email or phone of affected tester (no customers): josdijosdjodniosnjd@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.2 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Default workspace has dependent multi level tags.
  1. Go to staging.new.expensify.com
  2. Go to Account > Expense rules.
  3. Click New rule.
  4. Create a new rule where if merchant contains Apple, Region (second level tag) will change to South.
  5. Go to workspace chat.
  6. Create an expense with Apple as merchant.
  7. Open the expense report.

Expected Result:

"State no longer valid" violation will not appear on the first level tag.

Actual Result:

"State no longer valid" violation appears on the first level tag when second level tag is applied via expense rule.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7077233_1771010647068.5.mp4

Bug7077233_1771010647073!Dependent_-_Multi_Level_tags_NEWW.csv

View all open jobs on GitHub

Activity

  1. added
    DeployBlockerCash
    Daily
    Bug
    on Feb 13, 2026
  2. melvin-bot commented on Feb 13, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #81454

  3. melvin-bot commented on Feb 13, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  4. melvin-bot commented on Feb 13, 2026

    @melvin-bot

    Triggered auto assignment to @heyjennahay (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  5. github-actions commented on Feb 13, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. OSBotify commented on Feb 13, 2026

    @OSBotify
    Contributor

    🔍 Investigation Summary

    Classification: Frontend bug
    Causing PR: #81454 - "feat: rule - support multilevel tags" by @situchan (High confidence)
    Related Issues: #81094 (original feature request)

    Recommendation: REVERT

    PR #81454 should be reverted from staging. The PR introduced support for multilevel tags in expense rules but has a critical bug with dependent tag validation.

    Labels: Keeping DeployBlockerCash (App deploy blocked), removing DeployBlocker if present (not a backend issue)

    📋 Detailed Analysis

    Evidence

    PR #81454 was merged on 2026-02-13 at 12:57:01Z and is included in the staging deploy checklist (9.3.19-1). The issue was reported shortly after on staging, confirming the timeline matches.

    The PR changed how tags are handled in expense rules:

    • Before: Rules could only set a single tag value for all tag levels
    • After: Rules can now set individual values for each tag level independently

    Verification

    The PR modifies key files related to tag handling in rules:

    • src/pages/settings/Rules/Fields/AddTagPage.tsx - Changed to handle individual tag levels using orderWeight parameter
    • src/pages/workspace/rules/MerchantRules/AddTagPage.tsx - Same change for merchant rules
    • src/libs/TagUtils.ts - Added trimTag() function to handle colon-delimited multi-level tags
    • src/libs/TransactionUtils/index.ts - Uses getTagArrayFromName() to split tags by colons

    Root Cause

    The bug occurs when a rule applies only a second-level tag (e.g., "Region") in a dependent multi-level tag system:

    1. User creates a rule: "If merchant contains Apple, set Region = South"
    2. Rule is applied, setting tag to something like :South (first level empty, second level set)
    3. Validation logic in ViolationsUtils.ts (specifically getTagViolationForIndependentTags at lines 142-158) checks each tag level independently
    4. First-level tag ("State") is found to be missing/invalid
    5. System creates TAG_OUT_OF_POLICY violation showing "State no longer valid"

    The issue is that dependent tags require parent tags to be set first, but the rule allows setting child tags independently without validating the parent requirement. The PR correctly implemented multilevel tag selection in rules UI but did not account for dependent tag validation rules.

    Why Revert?

    1. This affects a core workflow (expense rules with dependent tags)
    2. The fix requires understanding the complex interplay between:
      • Tag dependency validation
      • Rule application logic
      • Multi-level tag parsing
    3. A proper fix needs to either:
      • Prevent rules from setting child tags without parents in dependent systems, OR
      • Skip violation checks for tags set by rules, OR
      • Apply parent tags automatically when child tags are set by rules
    4. Rolling forward would require significant testing with dependent vs independent tag systems
  7. situchan commented on Feb 13, 2026

    @situchan
    Contributor

    checking

  8. 2 remaining items

  9. MelvinBot commented on Feb 13, 2026

    @MelvinBot
    Contributor

    Proposal

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

    When a workspace has dependent multi-level tags and an expense rule sets only a 2nd-level tag (e.g., Region = "South") without setting the 1st-level tag (e.g., State), the transaction displays a "State no longer valid" (tagOutOfPolicy) violation on the 1st-level tag. This is incorrect -- the expected behavior is either no violation or the more appropriate "All tags required" message.

    What is the root cause of that problem?

    There are two layers to this bug, both stemming from PR #81454 introducing partial multi-level tag support in expense rules:

    Layer 1 -- How the rule stores partial tags:

    When a user configures a rule to set only the 2nd-level tag, src/pages/settings/Rules/Fields/AddTagPage.tsx:47-50 builds the tag string by joining tag levels with colons and calling trimTag(). For a 2-level system where only the 2nd level (orderWeight=1) is set to "South":

    • newTags = ['', 'South']
    • newTags.join(':') = ':South'
    • trimTag(':South') = ':South' (only trailing colons are stripped per src/libs/TagUtils.ts:17-19)

    This :South string (empty 1st level, "South" 2nd level) is stored as the rule's tag value and applied to transactions.

    Layer 2 -- Server-side violation computation generates the wrong violation type:

    The client-side violation code correctly handles this case. getTagViolationsForDependentTags at line 97-104:

    1. Parses ':South' via getTagArrayFromName into ['', 'South']
    2. Detects tags.includes('') is true (line 98)
    3. Pushes ALL_TAG_LEVELS_REQUIRED ("All tags required") -- NOT TAG_OUT_OF_POLICY

    The client code never generates TAG_OUT_OF_POLICY for dependent tags -- that logic only exists in getTagViolationForIndependentTags at lines 142-157, which is only reached when hasDependentTags = false.

    However, the server computes its own violations and returns them via API response Onyx updates, which overwrite the client's correct optimistic violations. The server generates TAG_OUT_OF_POLICY with data.tagName = "State" for the empty first-level tag, which renders as "State no longer valid" (per src/languages/en.ts:7716).

    Evidence this is server-generated:

    • Client's getTagViolationsForDependentTags (lines 85-108) only produces MISSING_TAG or ALL_TAG_LEVELS_REQUIRED, never TAG_OUT_OF_POLICY
    • getTagViolationsForMultiLevelTags at lines 177-183 strips all existing tag violations before re-computing, but the server response arrives after and overwrites
    • The violation message "State no longer valid" uses the tagOutOfPolicy translation, not allTagLevelsRequired ("All tags required")

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

    The fix should be server-side: the backend violation computation needs to properly distinguish dependent vs independent multi-level tags. For dependent tags with partial values like :South, the server should return ALL_TAG_LEVELS_REQUIRED instead of TAG_OUT_OF_POLICY with the first-level tag name.

    If a server-side fix is not feasible in the short term, a client-side workaround can be applied: after receiving server violations via Onyx updates, re-run the client-side violation computation (which already handles this correctly) to normalize the violations. This could be done by ensuring getViolationsOnyxData is called after server violations are received, similar to how it's already called optimistically during expense creation at src/libs/actions/IOU/index.ts:2562-2570.

    What alternative solutions did you explore? (Optional)

    Alternative 1 -- Prevent rules from setting partial tags for dependent tag systems: In AddTagPage.tsx, when the policy has dependent tags, require all tag levels to be set when any level is set. This prevents the :South tag string from being stored, but limits the feature's functionality.

    Alternative 2 -- Client-side post-processing of server violations: Add logic in the Onyx subscription for TRANSACTION_VIOLATIONS to detect and replace TAG_OUT_OF_POLICY violations with the correct violation type for dependent tag policies. This is a workaround rather than a root fix.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  10. added
    Reviewing
    on Feb 16, 2026
  11. IuliiaHerets commented on Feb 16, 2026

    @IuliiaHerets

    @mountiny issue is still repro, Chrome / v9.3.19-4

    Screen.Recording.2026-02-16.at.14.16.35.mp4
  12. mountiny commented on Feb 16, 2026

    @mountiny
    Contributor

    Testing the revert

  13. m-natarajan commented on Feb 16, 2026

    @m-natarajan

    Not repro but the tag set in rules is also not displayed and no violation appears, Windows 11 / Chrome

    applee.mp4
  14. situchan commented on Feb 16, 2026

    @situchan
    Contributor

    @mountiny issue is still repro, Chrome / v9.3.19-4

    Screen.Recording.2026-02-16.at.14.16.35.mp4

    Looks like you tested with the account set with wrong rule before the fix PR.

  15. added
    Daily
    and removed
    DeployBlockerCash
    Hourly
    on Feb 16, 2026
  16. m-natarajan commented on Feb 16, 2026

    @m-natarajan

    Not repro, No multilevel tag option in Expense rules (Reverted). Wim 11/Chrome, 9.3.19-5

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

Metadata

Metadata

Labels

BugDailyEngineeringReviewing

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions