Skip to content

[Due for payment 2025-09-12] [$250] Tags - "no longer valid" violation remains after switching tag level and selecting new tag #68263

Closed

Description

@lanitochka17

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.1.92-1
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://test-management.browserstack.com/projects/2219752/test-runs/TR-119/folder/13176676/41237318/830240442
Email or phone of affected tester (no customers): sjodijnsojdsoij@gmail.com
Issue reported by: Applause - Internal Team

Action Performed:

Precondition:

  • Workspace has imported multi level independent tags
  • "Members must tag all expenses" is enabled in Tags > More > Settings
  • Mark all tag levels as Required (enable the toggle)
  1. Go to staging.new.expensify.com
  2. Go to workspace chat
  3. Submit an expense and add all tag levels
  4. Go to workspace settings > Tags
  5. Click More > Import spreadsheet
  6. Click Single level of tags
  7. Click Switch Tag Levels
  8. Close the RHP
  9. Click Add tag
  10. Add a tag
  11. Go back to the transaction thread ini Step 3
  12. Click Tag
  13. Select the added single level tag in Step 9

Expected Result:

"no longer valid" violation should be dismissed after selecting a new tag

Actual Result:

"no longer valid" violation remains after switching tag level from multi to single and selecting a new tag
This is because the other tag level fields from the previous multi level tags are hidden now and the expense still has the previous multi level tags selected, but there is no way to deselect them

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop
Platforms Tested: On which of our officially supported platforms was this issue tested:
  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Bug6913022_1754834129604.Screen_Recording_2025-08-10_at_21.43.22.mp4

Bug6913022_1754834129606!Independent.-.Multi.Level.tags.csv

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021955357801454231388
  • Upwork Job ID: 1955357801454231388
  • Last Price Increase: 2025-08-12
  • Automatic offers:
    • nkdengineer | Contributor | 108411579
Issue OwnerCurrent Issue Owner: @twisterdotcom

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Aug 10, 2025
  2. melvin-bot commented on Aug 10, 2025

    @melvin-bot

    Triggered auto assignment to @twisterdotcom (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.

  3. nkdengineer commented on Aug 11, 2025

    @nkdengineer
    Contributor

    Proposal

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

    "no longer valid" violation remains after switching tag level from multi to single and selecting a new tag
    This is because the other tag level fields from the previous multi level tags are hidden now and the expense still has the previous multi level tags selected, but there is no way to deselect them

    What is the root cause of that problem?

    1. After selecting the multi level tags, the tags is A:B:C
    2. Switching tag level cause hasMultipleTagLists is false
    3. Select the new single tag (S), we update the tag by triggering insertTagIntoTransactionTagsString

    updatedTag = insertTagIntoTransactionTagsString(transactionTag, isSelectedTag ? '' : searchText, tagListIndex);

    In this function, we inserts a newly selected tag into the already existing tags like a string

    App/src/libs/IOUUtils.ts

    Lines 167 to 176 in 54e5acb

    function insertTagIntoTransactionTagsString(transactionTags: string, tag: string, tagIndex: number): string {
    const tagArray = getTagArrayFromName(transactionTags);
    tagArray[tagIndex] = tag;
    while (tagArray.length > 0 && !tagArray.at(-1)) {
    tagArray.pop();
    }
    return tagArray.map((tagItem) => tagItem.trim()).join(CONST.COLON);
    }

    but tagArray in this case is 'A:B:C' (old value), so the updated tag is S:B:C

    1. S:B:C is not in the policy so we don't update the violation

    if (hasTagOutOfPolicyViolation && updatedTransaction.tag && isTagInPolicy) {

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

    We should update this logic

    updatedTag = insertTagIntoTransactionTagsString(transactionTag, isSelectedTag ? '' : searchText, tagListIndex);

    to return the selected tag if policy?.hasMultipleTagLists is false

    if (!policy?.hasMultipleTagLists) {
                    updatedTag = isSelectedTag ? '' : searchText;
                } else {
                    // Independent tags (fallback): use comma-separated list
                    updatedTag = insertTagIntoTransactionTagsString(transactionTag, isSelectedTag ? '' : searchText, tagListIndex);
                }
    

    we also consider to early return tag if policy?.hasMultipleTagLists is false in insertTagIntoTransactionTagsString function

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    Update insertTagIntoTransactionTagsString to cover this case

    What alternative solutions did you explore? (Optional)

    We can use the condition here to detect if it's the single tag

    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.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Aug 12, 2025
  5. changed the title [-]Tags - "no longer valid" violation remains after switching tag level and selecting new tag[/-] [+][$250] Tags - "no longer valid" violation remains after switching tag level and selecting new tag[/+] on Aug 12, 2025
  6. melvin-bot commented on Aug 12, 2025

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Aug 12, 2025
  8. melvin-bot commented on Aug 12, 2025

    @melvin-bot

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

  9. mukhrr commented on Aug 13, 2025

    @mukhrr
    Contributor

    Proposal

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

    After switching a workspace from multi-level independent tags to a single-level tag setup, selecting a new single-level tag does not dismiss the “Tag no longer valid” violation on existing expenses.

    What is the root cause of that problem?

    Transactions can retain colon-delimited multi-level tag values (e.g., “Level1:Level2:Level3”). Single-level validation was checking the full transaction.tag string, so hidden, previously selected deeper levels caused the out-of-policy violation to persist.

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

    We should update getTagViolationsForSingleLevelTags in src/libs/Violations/ViolationsUtils.ts to validate only the first tag level:

    • Use TransactionUtils.getTag(updatedTransaction, 0) to derive the selected single-level tag.
    • Drive “missing tag” and “tag out of policy” logic using this first-level value only.
        const selectedTag = TransactionUtils.getTag(updatedTransaction, 0);

    And updatedTransaction.tag should be replaced by selectedTag in L33, L37, L42 and L52

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    N/A

    What alternative solutions did you explore? (Optional)

    Stripping trailing levels from transaction.tag on policy change.

  10. s77rt commented on Aug 14, 2025

    @s77rt
    Member

    @nkdengineer Thanks for the proposal. RCA makes sense and solution looks good to me.

    🎀 👀 🎀 C+ reviewed
    Link to proposal

  11. 10 remaining items

  12. changed the title [-][$250] Tags - "no longer valid" violation remains after switching tag level and selecting new tag[/-] [+][Due for payment 2025-09-12] [$250] Tags - "no longer valid" violation remains after switching tag level and selecting new tag[/+] on Sep 5, 2025
  13. melvin-bot commented on Sep 5, 2025

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  14. melvin-bot commented on Sep 5, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.1-20 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2025-09-12. 🎊

    For reference, here are some details about the assignees on this issue:

  15. melvin-bot commented on Sep 5, 2025

    @melvin-bot

    @grgia @twisterdotcom @s77rt / @nkdengineer The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  16. s77rt commented on Sep 7, 2025

    @s77rt
    Member

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: Allow for multiple levels of tags on workspace #34983 (comment)

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: n/a

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

      Bug requires regression test: Yes

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue: https://github.com/Expensify/Expensify/issues/544921

    Regression Test Proposal

    Precondition:

    • Workspace has multi level independent tags
    • "Members must tag all expenses" is enabled in Tags > More > Settings
    • Mark all tag levels as Required (enable the toggle)

    Test:

    1. Go to workspace chat
    2. Create an expense and add all tag levels
    3. Go to workspace settings > Tags
    4. Click More > Import spreadsheet
    5. Click Single level of tags
    6. Click Switch Tag Levels
    7. Close the RHP
    8. Click Add tag
    9. Add a tag
    10. Go back to the transaction thread in Step 2
    11. Verify you see "no longer valid" violation on Tag
    12. Click Tag
    13. Select the added single level tag in Step 9
    14. Verify that "no longer valid" violation is dismissed

    Do we agree 👍 or 👎

  17. twisterdotcom commented on Sep 11, 2025

    @twisterdotcom
    Contributor

    Payment Summary:

  18. JmillsExpensify commented on Sep 12, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @s77rt

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions