Skip to content

fix: System message with no tag is shown - #86864

Merged
luacmartins merged 16 commits into
Expensify:mainfrom
truph01:fix/82690
Sep 8, 2026
Merged

luacmartins merged 16 commits into
Expensify:mainfrom
truph01:fix/82690

Conversation

@truph01

@truph01 truph01 commented Apr 1, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

In this PR, rules keep their original tag values even after the tag is deleted. Instead, the frontend skips displaying the tag when it no longer exists in the policy:

  • MerchantRulesSection: getRuleDescription skips the tag line in the rule summary if the tag was deleted from the policy.
  • MerchantRulePageBase: The tag field in the rule edit page shows empty (undefined) instead of the deleted tag name.

Fixed Issues

$ #82690
PROPOSAL: #82690 (comment)

Tests

Test 1: Rule will not apply if the tag was deleted.

  • Precondition:

    • Workspace has at least one tag (Example "Tag 1").
    • Rules are enabled.
  1. Go to ND
  2. Go to workspace settings > Rules.
  3. Click Add merchant rule.
  4. Create a rule which applies when Apple is merchant, Tag will update to "Tag 1" .
  5. Go to Tags. Delete the tag used in the merchant rule in Step 4.
  6. Go to workspace chat. Create an expense with Apple as merchant. Open the expense report.
  7. Expected Result: Expense report will not show tag system message because the tag is deleted.

Test 2: The tag is not displayed in the merchant rule after the tag is deleted

  1. Go to ND.
  2. Navigate to Workspace settings > Rules.
  3. Click Add merchant rule.
  4. Create a rule that applies when Apple is the merchant and updates the tag to "Tag 1".
  5. Go to Tags and delete the tag used in the merchant rule from Step 4.
  6. Open the rule created in Step 4.
  7. Verify that "Tag 1" is no longer displayed in the rule.
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  • 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 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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@codecov

codecov Bot commented Apr 1, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
src/libs/PolicyUtils.ts 79.62% <95.45%> (+0.19%) ⬆️
src/pages/workspace/rules/MerchantRulesSection.tsx 67.10% <75.00%> (+0.43%) ⬆️
src/pages/settings/Rules/Fields/AddTagPage.tsx 0.00% <0.00%> (ø)
...pages/workspace/rules/MerchantRules/AddTagPage.tsx 0.00% <0.00%> (ø)
...space/rules/MerchantRules/MerchantRulePageBase.tsx 0.00% <0.00%> (ø)
... and 49 files with indirect coverage changes

@truph01 truph01 changed the title fix: System message with no tag is shown [Hold BE] fix: System message with no tag is shown Apr 3, 2026
@truph01
truph01 marked this pull request as ready for review April 3, 2026 03:28
@truph01
truph01 requested review from a team as code owners April 3, 2026 03:28
@melvin-bot
melvin-bot Bot requested review from brunovjk and removed request for a team April 3, 2026 03:28
@melvin-bot

melvin-bot Bot commented Apr 3, 2026

Copy link
Copy Markdown

@brunovjk 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]

@melvin-bot
melvin-bot Bot requested review from heyjennahay and removed request for a team April 3, 2026 03:28
@truph01 truph01 changed the title [Hold BE] fix: System message with no tag is shown [HOLD BE] fix: System message with no tag is shown Apr 3, 2026
@luacmartins
luacmartins self-requested a review July 21, 2026 21:09
@truph01

truph01 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

@brunovjk I resolved conflicts

@truph01 truph01 changed the title [HOLD BE] fix: System message with no tag is shown fix: System message with no tag is shown Jul 22, 2026
@brunovjk

Copy link
Copy Markdown
Contributor

@truph01 If I delete a tag and then go back to a rule created using that tag, the tag still appears as selected, even though it no longer exists as an option to select. The rule continues to use the deleted tag; Do you think this is still within the scope of this PR?

Screen.Recording.2026-07-22.at.11.42.20.mov

Thanks.

@truph01

truph01 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

#82690

@brunovjk I asked here #82690 (comment)

@luacmartins

Copy link
Copy Markdown
Contributor

@truph01 I left a comment in the issue

@luacmartins

Copy link
Copy Markdown
Contributor

@truph01 any updates based on my comment above?

@luacmartins

Copy link
Copy Markdown
Contributor

@truph01 any updates on this one?

@luacmartins

Copy link
Copy Markdown
Contributor

@truph01 any updates on this one?

@truph01

truph01 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Dependent tags can have the same name and be differentiated by parentTagsFilter. The current validation seems to match only by key/name, so could it resolve a tag belonging to a different parent and incorrectly show or hide it?

@brunovjk I resolved your concern via ddcaad3


On a direct visit or with a clean cache, policyTags may still be undefined. In that case, isTagInPolicy() returns false and could hide valid tags before the data is loaded. Should we call openPolicyTagsPage() here or distinguish “not loaded” from “does not exist”?

@luacmartins About this one, which approach do you prefer?

I think calling openPolicyTagsPage() would be simpler, but it might violate our 1:1:1 rule.

@luacmartins

Copy link
Copy Markdown
Contributor

Is that comment true? Don't we load the tag list with the policy?

@luacmartins

Copy link
Copy Markdown
Contributor

@truph01 bump

1 similar comment
@luacmartins

Copy link
Copy Markdown
Contributor

@truph01 bump

@truph01

truph01 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Don't we load the tag list with the policy?

@luacmartins No. The tags need to be fetched via the OpenPolicyTagsPage call. They aren't always available just because the user is viewing the policy.

@luacmartins

Copy link
Copy Markdown
Contributor

Ok, where are we planning on calling OpenPolicyTagsPage?

@truph01

truph01 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Ok, where are we planning on calling OpenPolicyTagsPage?

@luacmartins I plan to call it there:

useEffect(() => {
// PolicyRulesPageRevamp fetches rules on its own mount — skip here to avoid duplicate OpenPolicyRulesPage calls.
if (isRulesRevampEnabled) {
return;
}
fetchRules();
}, [fetchRules, isRulesRevampEnabled]);

@luacmartins

Copy link
Copy Markdown
Contributor

Hmm then I think we should just add that data to the response of OpenPolicyRulesPage which already returns policy data. I can work on the BE changes for that.

@luacmartins

Copy link
Copy Markdown
Contributor

@luacmartins

Copy link
Copy Markdown
Contributor

I don't think we need to hold this PR on the BE given it's a small edge case.

@luacmartins luacmartins left a comment

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.

LGTM

@luacmartins
luacmartins merged commit bc098e0 into Expensify:main Sep 8, 2026
36 of 38 checks passed
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

🚧 luacmartins has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

OSBotify commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify OSBotify mentioned this pull request Sep 9, 2026
83 tasks done
@OSBotify

OSBotify commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/luacmartins in version: 9.4.75-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Help site changes are required. Draft PR: #100743

This PR changes user-visible Merchant Rules behavior that the help site described inaccurately: a rule that applies a deleted tag now skips that tag instead of showing or applying an empty value, and the tag picker in a rule now only lists tags valid under the levels already selected.

What the docs PR changes — docs/articles/new-expensify/workspaces/Workspace-Merchant-Rules.md:

  • New behavior bullet under How Merchant Rules are applied: deleting a tag stops only that update; the rule's other updates still apply.
  • Added the deleted tag to Why didn't my Merchant Rule apply?.
  • New FAQ: What happens to a Merchant Rule when the tag it applies is deleted? — what admins see in the rule summary and the rule's Tag field, and how to set a tag again.
  • New FAQ: Why don't all of my tags appear when I select Tag in a Merchant Rule? — disabled tags and multi-level tag filtering.
  • Fixed the save step to the exact UI label Save rule (the article said "Save Rule").
  • Added keywords for deleted-tag searches.
How the change was mapped to the docs
  • MerchantRulesSection.tsx — getRuleDescription now skips the tag line when isTagInPolicy is false, so the rule summary no longer lists the tag update.
  • MerchantRulePageBase.tsx — the tag row title is undefined when the matched tag is missing or pending delete, so the Tag field shows empty.
  • MerchantRules/AddTagPage.tsx and settings/Rules/Fields/AddTagPage.tsx — tag options are filtered by matchesParentTagPath, so each level lists only tags valid under the selected parents.
  • No other article needed changes: Import-Merchant-Rules.md covers spreadsheet import only, and Personal-Expense-Rules.md covers a flow this PR's display fix doesn't touch.

Article was written against docs/HELPSITE_NAMING_CONVENTIONS.md, docs/HELP_AUTHORING_GUIDELINES.md, and docs/TEMPLATE.md.

Label verification caveat: the live UI check didn't run — the web test session never rendered the app (blank page, no accessibility nodes), so the labels Merchant, Add merchant rule, Save rule, and Tag were verified against the strings in src/languages/en.ts instead. Please confirm them when you review.

@truph01, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review

@jponikarchuk

Copy link
Copy Markdown

@truph01 @brunovjk @luacmartins Could you please confirm if this is an issue that Merchant rule can be saved without applying any updates & tag row is shown
Steps:
Pre-condition:
1.Enable tag and add a tag
2.Create a merchant rule with merchant test and tag created.
3. Delete the tag

  1. Launch app
  2. Open the rule
  3. Tap tag - none
  4. Note please apply atleast 1 rule is shown on saving the rule
  5. Navigate back and open rule again
  6. Tap save rule note no error is shown and note tag row is shown when there is no tag added in workspace

Actual Result: Merchant rule can be saved without applying any updates. Tag row is shown when there are no added tags in workspace even while resaving.
Note : Tag row is not shown only after clearing cache

Bug7256047_1789043610576.Screenrecorder-2026-09-10-17-58-36-958.mp4

@luacmartins

Copy link
Copy Markdown
Contributor

I think that's fine for now, although we shouldn't show the rule if it's not applying any updates

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.4.75-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 failure ❌
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.4.75-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 failure ❌
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

dmkt9 pushed a commit to dmkt9/ExpensifyApp that referenced this pull request Sep 16, 2026
Follow-up to Expensify#86864.

Co-authored-by: truph01 <truph01@users.noreply.github.com>
@situchan situchan mentioned this pull request Oct 8, 2026
45 tasks done
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.

6 participants