You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rules - Existing expenses not updated after applying merchant rule and no system message #82914
Version Number: v9.3.22-1 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:#82438 Email or phone of affected tester (no customers):applausetester+piyomn@applause.expensifail.com Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: iPhone 13 / iOS 18.7.1, Samsung Galaxy A52 / Android 14, Windows 11 / Chrome App Component: Workspace Settings
Action Performed:
Preconditions: account has at least one workspace with rules in more feature enabled
Steps:
Create several unsubmitted expenses with merchant "Starbucks" (I created 3 expenses)
Navigate to workspace setting -> Rules -> Add merchant rule
Create the merchant rule with "Starbucks" as the merchant, configure description and any categories except "Meals and Entertainment" (I choose "materials" for categories)
Toggle on the "apply to existing unsubmitted expenses"
Click the "Preview matches" button to make sure there's unsubmitted expenses there and and save it
Navigate to the workspace chat
Click on the newly created report with several expenses
Click on any individual expense
Expected Result:
in step 6, merchant should updated to "Materials", like the description that auto updated to "Jajan" after "Apply to existing unsubmitted expenses" is toggled on in Step 4
in step 7, there should be a system message appeared on the update expenses since the description is updated.
Actual Result:
in step 6, merchant doesn't updated to "Materials" like the description that auto updated to "Jajan" after "Apply to existing unsubmitted expenses" is toggled on in Step 4
in step 7, the system message doesn't appeared on the update expense. there's only concierge system message from the original auto selected category before the merchant rule applied.
👋 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:
Identify the pull request that introduced this issue and revert it.
Classification: Frontend bug Causing PR: #82438 - "Enable merchant rules v2" by @luacmartins (High confidence) Related Issues: #82225 (similar issue from previous merchant rules enable attempt)
Recommendation: REVERT
PR #82438 enabled the merchant rules feature by removing the production gate. While the bug exists in the backend API logic (which partially applies rules - updating description but not merchant field), reverting the App PR is the correct action to prevent shipping broken functionality to users. The feature should remain hidden until the backend correctly implements the full merchant rule application including merchant field updates and system messages.
Labels: Keeping DeployBlockerCash (App deploy blocked until revert)
📋 Detailed Analysis
Evidence
PR #82438 removed only the isProduction check from MerchantRulesSection.tsx, making the merchant rules feature visible to all users. The feature was previously gated and this PR enabled it for the first time in this deploy cycle.
The issue describes that when applying a merchant rule with "apply to existing unsubmitted expenses" toggled:
Description field updates correctly ✓
Merchant field does NOT update ✗
No system message appears ✗
This matches the behavior described in issue #82225 from the previous merchant rules enable attempt (PR #81033), which was also reverted due to similar issues.
The change removed the production gate: if (isProduction) { return null; }
This directly enabled the merchant rules feature that exhibits the reported bug
The issue is reproducible on staging (where PR Enable merchant rules v2 #82438 is deployed) but N/A on production (where the feature doesn't exist)
Root Cause
The frontend correctly passes shouldUpdateMatchingTransactions: true to the backend API (SET_POLICY_CODING_RULE). The backend API is responsible for updating matching transactions but only partially applies the rule - it updates the description field but fails to update the merchant field and generate system messages.
While the root cause is a backend bug, the correct action per deploy blocker protocol is to revert the App PR that exposed the broken feature to users, then address the backend bug before re-enabling the feature.
Please re-state the problem that we are trying to solve in this issue.
When creating a merchant rule with "Apply to existing unsubmitted expenses" toggled ON, the category field is not applied to matching existing expenses, even though the description field IS applied correctly. Additionally, no system message appears for the category update on the affected expenses.
What is the root cause of that problem?
The root cause is in the backend SetPolicyCodingRule command handler, not in the frontend App code. Here's why:
The frontend correctly sends all rule fields (category, description/comment, tag, tax, merchant, reimbursable, billable) to the backend via the SetPolicyCodingRule API command. Specifically:
mapFormFieldsToRuleForAPI() in src/libs/actions/Policy/Rules.ts:71-99 builds the complete rule object — both category and comment (description) are included identically using the same truthy-check pattern.
The rule is JSON-stringified into the codingRuleValue parameter alongside shouldUpdateMatchingTransactions: true (src/libs/actions/Policy/Rules.ts:219-224).
The frontend creates zero optimistic transaction updates or report actions — it only optimistically updates the policy's codingRules record (src/libs/actions/Policy/Rules.ts:170-217). The entire "apply to existing" logic is delegated to the backend.
The backend handler for SetPolicyCodingRule is responsible for: (a) finding matching transactions, (b) updating their fields, and (c) creating MODIFIEDEXPENSE report actions with policyRulesModifiedFields in the original message. The backend appears to handle comment (description) correctly but skips category when applying the rule to existing transactions.
The frontend rendering code for policy-rules-modified system messages is fully implemented and ready — getPolicyRulesModifiedMessage() in src/libs/ModifiedExpenseMessage.ts:205-242 explicitly handles the category key and would render the message correctly if the backend created the report action.
What changes do you think we should make in order to solve the problem?
The fix needs to be made in the backendSetPolicyCodingRule command handler (likely in Web-Expensify or Auth). When shouldUpdateMatchingTransactions is true, the handler must:
Apply all rule fields to matching transactions — not just comment (description), but also category, tag, tax, merchant, reimbursable, and billable.
Create MODIFIEDEXPENSE report actions for each modified transaction with policyRulesModifiedFields containing all changed fields (including category) and the policyID, so the frontend can render the system messages.
No changes are needed in the App (frontend) repo — the form submission, API parameter construction, and system message rendering are all correctly implemented.
What alternative solutions did you explore? (Optional)
Considered whether this could be a frontend issue where the category field is omitted from the API payload, but traced the complete data flow and confirmed both category and comment are sent identically via mapFormFieldsToRuleForAPI(). Also considered whether optimistic data might need to update transactions client-side, but this would be impractical since the frontend doesn't know which transactions match — the backend must handle matching and updating.
Next Steps for Contributor+ team: This is a backend-only bug. The SetPolicyCodingRule handler needs to be investigated to confirm which fields it applies to matching transactions when shouldUpdateMatchingTransactions=true. Reply with @MelvinBot <your feedback> to refine this analysis.
Activity
melvin-bot commentedon Feb 19, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #82438
melvin-bot commentedon Feb 19, 2026
💬 A slack conversation has been started in #expensify-open-source
melvin-bot commentedon Feb 19, 2026
Triggered auto assignment to @brianlee-expensify (
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.github-actions commentedon Feb 19, 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:
OSBotify commentedon Feb 19, 2026
🔍 Investigation Summary
Classification: Frontend bug
Causing PR: #82438 - "Enable merchant rules v2" by @luacmartins (High confidence)
Related Issues: #82225 (similar issue from previous merchant rules enable attempt)
Recommendation: REVERT
PR #82438 enabled the merchant rules feature by removing the production gate. While the bug exists in the backend API logic (which partially applies rules - updating description but not merchant field), reverting the App PR is the correct action to prevent shipping broken functionality to users. The feature should remain hidden until the backend correctly implements the full merchant rule application including merchant field updates and system messages.
Labels: Keeping
DeployBlockerCash(App deploy blocked until revert)📋 Detailed Analysis
Evidence
PR #82438 removed only the
isProductioncheck fromMerchantRulesSection.tsx, making the merchant rules feature visible to all users. The feature was previously gated and this PR enabled it for the first time in this deploy cycle.The issue describes that when applying a merchant rule with "apply to existing unsubmitted expenses" toggled:
This matches the behavior described in issue #82225 from the previous merchant rules enable attempt (PR #81033), which was also reverted due to similar issues.
Verification
src/pages/workspace/rules/MerchantRulesSection.tsxif (isProduction) { return null; }Root Cause
The frontend correctly passes
shouldUpdateMatchingTransactions: trueto the backend API (SET_POLICY_CODING_RULE). The backend API is responsible for updating matching transactions but only partially applies the rule - it updates the description field but fails to update the merchant field and generate system messages.While the root cause is a backend bug, the correct action per deploy blocker protocol is to revert the App PR that exposed the broken feature to users, then address the backend bug before re-enabling the feature.
MelvinBot commentedon Feb 19, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When creating a merchant rule with "Apply to existing unsubmitted expenses" toggled ON, the category field is not applied to matching existing expenses, even though the description field IS applied correctly. Additionally, no system message appears for the category update on the affected expenses.
What is the root cause of that problem?
The root cause is in the backend
SetPolicyCodingRulecommand handler, not in the frontend App code. Here's why:The frontend correctly sends all rule fields (category, description/comment, tag, tax, merchant, reimbursable, billable) to the backend via the
SetPolicyCodingRuleAPI command. Specifically:mapFormFieldsToRuleForAPI()insrc/libs/actions/Policy/Rules.ts:71-99builds the complete rule object — bothcategoryandcomment(description) are included identically using the same truthy-check pattern.codingRuleValueparameter alongsideshouldUpdateMatchingTransactions: true(src/libs/actions/Policy/Rules.ts:219-224).codingRulesrecord (src/libs/actions/Policy/Rules.ts:170-217). The entire "apply to existing" logic is delegated to the backend.The backend handler for
SetPolicyCodingRuleis responsible for: (a) finding matching transactions, (b) updating their fields, and (c) creatingMODIFIEDEXPENSEreport actions withpolicyRulesModifiedFieldsin the original message. The backend appears to handlecomment(description) correctly but skipscategorywhen applying the rule to existing transactions.The frontend rendering code for policy-rules-modified system messages is fully implemented and ready —
getPolicyRulesModifiedMessage()insrc/libs/ModifiedExpenseMessage.ts:205-242explicitly handles thecategorykey and would render the message correctly if the backend created the report action.What changes do you think we should make in order to solve the problem?
The fix needs to be made in the backend
SetPolicyCodingRulecommand handler (likely in Web-Expensify or Auth). WhenshouldUpdateMatchingTransactionsistrue, the handler must:comment(description), but alsocategory,tag,tax,merchant,reimbursable, andbillable.MODIFIEDEXPENSEreport actions for each modified transaction withpolicyRulesModifiedFieldscontaining all changed fields (includingcategory) and thepolicyID, so the frontend can render the system messages.No changes are needed in the App (frontend) repo — the form submission, API parameter construction, and system message rendering are all correctly implemented.
What alternative solutions did you explore? (Optional)
Considered whether this could be a frontend issue where the category field is omitted from the API payload, but traced the complete data flow and confirmed both
categoryandcommentare sent identically viamapFormFieldsToRuleForAPI(). Also considered whether optimistic data might need to update transactions client-side, but this would be impractical since the frontend doesn't know which transactions match — the backend must handle matching and updating.Next Steps for Contributor+ team: This is a backend-only bug. The
SetPolicyCodingRulehandler needs to be investigated to confirm which fields it applies to matching transactions whenshouldUpdateMatchingTransactions=true. Reply with@MelvinBot <your feedback>to refine this analysis.luacmartins commentedon Feb 19, 2026
We reverted the offending PR. NAB. PR to fix this is in review.
luacmartins commentedon Mar 3, 2026
This is done