Repository navigation
Description
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.31-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: #83005
Email or phone of affected tester (no customers): sodijsojosjsdoj@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:
- Rules are enabled.
- Go to staging.new.expensify.com
- Go to workspace settings > Rules.
- Click Add merchant rule.
- Create a rule where category changes to Car when merchant is Apple.
- Create a second rule where category changes to Fees when merchant is Apple.
- Open the first rule from Step 4.
- Click Category, change it to Labor and click Save.
- Click Save rule.
→ "Your existing rule for "Apple" will take priority over this one" is shown when this is the original/first rule. - Click Save anyway.
- Go to workspace chat.
- Create an expense with Apple merchant without category.
- Open the expense.
→ Category is changed to Labor, which means the first rule is prioritised. "Your existing rule for "Apple" will take priority over this one" in Step 8 is confusing as it indicates that the second rule will take priority over "this one".
Expected Result:
In Step 8, when editing the original/first rule, Your existing rule for "Apple" will take priority over this one" will not appear.
Actual Result:
In Step 8, when editing the original/first rule, Your existing rule for "Apple" will take priority over this one" is shown.
In Step 12, when merchant rule is applied, the first rule is prioritised.
"Your existing rule for "Apple" will take priority over this one" in Step 8 is confusing as it indicates that the second rule will take priority over "this one" when the original rule is edited.
Workaround:
Unknown
Platforms:
- Android: App
- Android: mWeb Chrome
- iOS: App
- iOS: mWeb Safari
- iOS: mWeb Chrome
- Windows: Chrome
- MacOS: Chrome / Safari
Screenshots/Videos
Bug7094008_1772653807950.15.mp4
Issue Owner
Current Issue Owner: @luacmartinsMetadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
melvin-bot commentedon Mar 4, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #83005
melvin-bot commentedon Mar 4, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Mar 4, 2026
👋 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:
melvin-bot commentedon Mar 4, 2026
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.OSBotify commentedon Mar 4, 2026
Investigation Summary
Classification: Frontend bug
Causing PR: #80545 - "Create merchant rule" by @luacmartins (High confidence)
Related Issues: #82239 (tried to fix with PR #82440, but that PR is not yet in this staging deploy)
Recommendation: ROLL FORWARD
The issue is in the merchant rule duplicate detection logic in
MerchantRulePageBase.tsx. When editing an existing rule to match another rules merchant, the duplicate warning always shows "Your existing rule for [merchant] will take priority over this one" - but this message is confusing when editing the FIRST/original rule because "this one" (the rule being edited) is actually the one that takes priority, not the "existing" duplicate that was created later.A fix should be relatively straightforward - the
checkForDuplicateRulefunction needs to either:Rolling forward with a fix is recommended over reverting because:
Labels: No label changes needed - keeping DeployBlockerCash as this is a frontend (App) issue
Detailed Analysis
Evidence
The bug report shows that when editing Rule 1 (created first, category=Car) to change it to category=Labor, after Rule 2 (category=Fees) was created with the same merchant, the warning message appears saying "Your existing rule for Apple will take priority over this one." This is confusing because "this one" refers to Rule 1 being edited, which is actually the original rule that takes priority.
Verification
I verified the
checkForDuplicateRulefunction insrc/pages/workspace/rules/MerchantRules/MerchantRulePageBase.tsx(lines 191-215). The function:The actual behavior (Rule 1 takes priority over Rule 2) is correct - this is just a confusing message.
Root Cause
The
checkForDuplicateRulefunction was introduced in PR #80545 when merchant rules were first created. It always assumes the rule being saved is the "new" one that will have lower priority, but when editing an older existing rule, this assumption is incorrect. The warning should either not appear in this case, or should dynamically determine which rule has priority and adjust the message accordingly.MelvinBot commentedon Mar 4, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user has two merchant rules for the same merchant (e.g., "Apple") and edits the original/first rule, a confusing confirmation modal appears saying: "Your existing rule for 'Apple' will take priority over this one. Save anyway?" This message implies the other (second) rule will take priority, but in reality the first rule is the priority rule — it was created earlier and takes precedence. The warning should not appear when editing the rule that already has priority.
What is the root cause of that problem?
The
checkForDuplicateRulefunction insrc/pages/workspace/rules/MerchantRules/MerchantRulePageBase.tsxcorrectly skips the rule being edited but finds any other rule with the same merchant name and match type, returning a simpleboolean. It does not consider which rule has priority based on creation order.When
handleSubmitdetects a duplicate, it always shows the same static prompt via theduplicateRulePrompttranslation (src/languages/en.ts):This message assumes "this one" (the rule being edited) is always the lower-priority rule. But when the user is editing the original/oldest rule, that assumption is wrong — the rule being edited IS the higher-priority rule, and the "existing" duplicate is actually the newer, lower-priority one.
The
createdtimestamp (which determines priority) is preserved on edits (src/libs/actions/Policy/Rules.ts:const created = existingRule?.created ?? new Date().toISOString()), so editing the first rule does not change its priority position.What changes do you think we should make in order to solve the problem?
Modify
checkForDuplicateRuleinMerchantRulePageBase.tsxto be priority-aware. Instead of returning a simple boolean, it should compare thecreatedtimestamps of the rule being edited against the duplicate rule found:false(no warning needed, since this rule already takes precedence)true(show the existing warning as-is)Specifically, inside the
.some()callback, after finding a matching rule, add a comparison ofexistingRule?.createdagainst the foundrule.created. If the rule being edited is older, skip the match.What alternative solutions did you explore? (Optional)
An alternative would be to keep showing the warning in both directions but change the message text depending on which rule has priority (e.g., "This rule will take priority over your other rule for 'Apple'"). However, this adds UI complexity and the issue's expected behavior states the warning should simply not appear when editing the original rule.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.
luacmartins commentedon Mar 5, 2026
@MelvinBot implement this
luacmartins commentedon Mar 5, 2026
I don't think we need to block on this
MelvinBot commentedon Mar 5, 2026
🤖 Draft PR created: #84224
Please mark it as "Ready for review" when it is ready for review.
JS00001 commentedon Mar 5, 2026
This is merged
luacmartins commentedon Mar 6, 2026
This is done