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 - Rules behavior unchanged after merchant match type is changed to 'Exactly matches" #82899
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+aqwa@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:
Prepare two accounts (Admin and Member)
As Admin create a workspace and invite the member to the workspace
Enable rules in more feature
Steps:
(Admin) navigate to rules in workspace setting, scroll down and add merchant rule:
(Admin) Change Match type from "Contains" to "Exactly matches" and save the rule
(Member) create an expense with merchant: "Starbucks Coffee"
Expected Result:
After member created the second expense when the rule already changed, the rule should not be applied (no longer contains match). Also there should be system message displayed on the expense details.
Actual Result:
Rules remain active after the admin updates the merchant match type to “exactly matches". Also, there's no system message displayed to show whether the category is automatically set by concierge or by the workspace rules.
👋 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: Backend bug Causing PR: #82438 - "Enable merchant rules v2" by @luacmartins (High confidence) Related Issues: None found
Recommendation: REVERT
PR #82438 enabled merchant rules in production by removing the production environment check. However, this exposed a backend bug where the rule matching logic does not properly respect updated match types (operator changes from "Contains" to "Exactly matches").
The App correctly sends the updated rule to the backend via the SET_POLICY_CODING_RULE API command. The bug occurs on the backend when applying rules to new transactions - the backend is not correctly evaluating the updated operator when matching merchant names.
Since this is a new feature that does not exist in production and the bug is in backend rule application logic (not in the App code), we should revert PR #82438 to restore the production check until the backend rule matching logic is fixed.
Labels: Removing DeployBlockerCash and keeping Bug label. This is a backend bug that blocks deployment but does not require App changes.
📋 Detailed Analysis
Evidence
PR #82438 removed the isProduction check from MerchantRulesSection.tsx, enabling merchant rules for all users. The PR only contains frontend changes - it removes 6 lines that prevented the merchant rules UI from being displayed in production.
The bug report shows that after editing a rule to change the match type from "Contains" to "Exactly matches", the rule continues to match using the old "Contains" behavior. This indicates the backend rule evaluation engine is not properly updating its matching logic when the operator changes.
Verification
Files affected by the bug:
Backend rule application logic (not in App repository)
The symptom appears when members create expenses, which triggers backend rule evaluation
Only modified src/pages/workspace/rules/MerchantRulesSection.tsx
Removed the production environment check that hid the merchant rules feature
No changes to rule creation, editing, or application logic
Root Cause
When an admin edits a merchant rule and changes the match type (operator), the App correctly:
Updates the form with the new matchType value (line 116 in MerchantRulePageBase.tsx)
Calls setPolicyCodingRule() with the updated form data (line 208)
Sends the updated rule to the API with the new operator (line 137-146 in Rules.ts)
However, the backend does not properly apply the updated operator when evaluating rules against new transactions. The backend continues to use the old matching behavior, suggesting either:
The backend is caching the old rule configuration
The backend rule evaluation logic has a bug in how it processes operator updates
The backend is not receiving or storing the updated operator correctly
This is purely a backend issue because:
Rule application happens server-side when expenses are created
The App only manages the rule UI and sends configurations to the API
No client-side rule matching occurs in the App codebase
Please re-state the problem that we are trying to solve in this issue.
Two issues with workspace merchant rules (CodingRules):
After an admin changes a merchant rule's match type from "Contains" to "Exactly matches" and saves, the old "Contains" behavior persists when a member creates a new expense. For example, a rule for "Coffee" that was changed to "Exactly matches" still matches "Starbucks Coffee" (contains behavior).
No system message is displayed on the expense to indicate that the category was auto-set by workspace rules.
What is the root cause of that problem?
Both issues are server-side bugs. Merchant rule matching is done entirely on the backend — the App frontend has zero rule-evaluation logic.
Evidence from code investigation:
Rule save is correct on the frontend: When saving a rule, setPolicyCodingRule() at App/src/libs/actions/Policy/Rules.ts:137-163 correctly reads the match type and includes it in the filters object:
This operator ('eq' for "Exactly matches", 'contains' for "Contains") is sent to the backend as part of the JSON-stringified codingRuleValue parameter via the SetPolicyCodingRule API.
No client-side rule matching: Expense creation via RequestMoney at App/src/libs/actions/IOU/index.ts sends raw transaction data to the backend with no reference to coding rules. All IOU action files have zero references to codingRule, expenseRule, or rule-matching logic.
System message mechanism exists but is backend-generated: The MODIFIEDEXPENSE report action type has a policyRulesModifiedFields property (App/src/types/onyx/OriginalMessage.ts:837-856) and the frontend renders it via getPolicyRulesModifiedMessage() at App/src/libs/ModifiedExpenseMessage.ts:205-241. But this message is generated by the backend — if it's missing, the backend isn't creating it.
Root cause hypotheses (backend — not inspectable from App repo):
Issue 1 (stale match type): The backend RequestMoney handler likely ignores or defaults the operator field when evaluating coding rules, always using "contains" semantics regardless of the stored operator. Alternatively, there may be a caching layer for policy rules that serves stale data after an update.
Issue 2 (missing system message): The backend may not be generating the MODIFIEDEXPENSE report action with policyRulesModifiedFields when coding rules are applied to new expenses (it may only generate them for retroactive updates via shouldUpdateMatchingTransactions).
What changes do you think we should make in order to solve the problem?
Since this is a backend issue, the fix needs to be in the Auth/Web-Expensify server code:
For the match type bug: The backend handler for RequestMoney (or its post-processing that applies coding rules) needs to be updated to respect the operator field from CodingRuleFilter. When operator is 'eq', it should require an exact match (case-insensitive) between the transaction merchant and filters.right. When operator is 'contains', it should check if the merchant string contains filters.right as a substring.
For the missing system message: The backend should generate a MODIFIEDEXPENSE report action with policyRulesModifiedFields whenever a coding rule is applied to a new expense, not only during retroactive updates. The frontend already has the rendering logic in place at ModifiedExpenseMessage.ts:205-241.
What alternative solutions did you explore? (Optional)
Investigated whether the matching could be done client-side as a workaround, but this would be architecturally wrong — the backend is the source of truth for rule evaluation, and the system message generation must also happen server-side. Moving matching client-side would create inconsistencies between platforms and bypass server-side validation.
Detailed Investigation
Architecture Overview
Workspace merchant rules are stored as CodingRule objects in policy.rules.codingRules (type defined at App/src/types/onyx/Policy.ts:1720-1756). Each rule has:
Rule creation/edit: Admin selects match type in AddMatchTypePage.tsx → stored in form as matchType → setPolicyCodingRule() builds filters.operator and sends SetPolicyCodingRule API
Expense creation: Member calls requestMoney() → sends RequestMoney API with raw expense data → backend evaluates rules → applies matching fields → generates MODIFIEDEXPENSE report action
System message: Backend generates policyRulesModifiedFields on MODIFIEDEXPENSE → frontend renders via getPolicyRulesModifiedMessage()
App/src/types/onyx/Policy.ts:1691-1756 - CodingRule type (includes operator in filters)
App/src/pages/workspace/rules/MerchantRules/AddMatchTypePage.tsx:41-58 - Match type selection UI
App/src/libs/ModifiedExpenseMessage.ts:205-241 - System message rendering
App/src/types/onyx/OriginalMessage.ts:837-856 - policyRulesModifiedFields type
Evidence Chain
Frontend save → SetPolicyCodingRule API with operator: 'eq' → Backend stores rule → Member creates expense → RequestMoney API → Backend should match using 'eq' semantics but appears to use 'contains' → Backend should generate system message but doesn't
Next Steps for Contributor+ team: This is a backend bug. The fix needs to be in the server-side code that handles RequestMoney and evaluates coding rules. The App frontend correctly sends and displays all the necessary data. Reply with @MelvinBot implement this to create a draft PR (if the fix is in the App repo), or @MelvinBot <your feedback> to refine this analysis.
This is not an issue. The rule is updated correctly, but we also have AgentZero auto-categorizing expenses. So when the user changed the rule to exactly matches the rule no longer applies, but AZ still auto-categorizes the expense as Meals & Entertainment which makes it seem like the rule is being applied.
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 @stephanieelliott (
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: Backend bug
Causing PR: #82438 - "Enable merchant rules v2" by @luacmartins (High confidence)
Related Issues: None found
Recommendation: REVERT
PR #82438 enabled merchant rules in production by removing the production environment check. However, this exposed a backend bug where the rule matching logic does not properly respect updated match types (operator changes from "Contains" to "Exactly matches").
The App correctly sends the updated rule to the backend via the
SET_POLICY_CODING_RULEAPI command. The bug occurs on the backend when applying rules to new transactions - the backend is not correctly evaluating the updated operator when matching merchant names.Since this is a new feature that does not exist in production and the bug is in backend rule application logic (not in the App code), we should revert PR #82438 to restore the production check until the backend rule matching logic is fixed.
Labels: Removing
DeployBlockerCashand keepingBuglabel. This is a backend bug that blocks deployment but does not require App changes.📋 Detailed Analysis
Evidence
PR #82438 removed the
isProductioncheck fromMerchantRulesSection.tsx, enabling merchant rules for all users. The PR only contains frontend changes - it removes 6 lines that prevented the merchant rules UI from being displayed in production.The bug report shows that after editing a rule to change the match type from "Contains" to "Exactly matches", the rule continues to match using the old "Contains" behavior. This indicates the backend rule evaluation engine is not properly updating its matching logic when the operator changes.
Verification
Files affected by the bug:
PR #82438 changes:
src/pages/workspace/rules/MerchantRulesSection.tsxRoot Cause
When an admin edits a merchant rule and changes the match type (operator), the App correctly:
matchTypevalue (line 116 in MerchantRulePageBase.tsx)setPolicyCodingRule()with the updated form data (line 208)However, the backend does not properly apply the updated operator when evaluating rules against new transactions. The backend continues to use the old matching behavior, suggesting either:
This is purely a backend issue because:
MelvinBot commentedon Feb 19, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
Two issues with workspace merchant rules (CodingRules):
What is the root cause of that problem?
Both issues are server-side bugs. Merchant rule matching is done entirely on the backend — the App frontend has zero rule-evaluation logic.
Evidence from code investigation:
Rule save is correct on the frontend: When saving a rule,
setPolicyCodingRule()atApp/src/libs/actions/Policy/Rules.ts:137-163correctly reads the match type and includes it in thefiltersobject:This operator (
'eq'for "Exactly matches",'contains'for "Contains") is sent to the backend as part of the JSON-stringifiedcodingRuleValueparameter via theSetPolicyCodingRuleAPI.No client-side rule matching: Expense creation via
RequestMoneyatApp/src/libs/actions/IOU/index.tssends raw transaction data to the backend with no reference to coding rules. All IOU action files have zero references tocodingRule,expenseRule, or rule-matching logic.System message mechanism exists but is backend-generated: The
MODIFIEDEXPENSEreport action type has apolicyRulesModifiedFieldsproperty (App/src/types/onyx/OriginalMessage.ts:837-856) and the frontend renders it viagetPolicyRulesModifiedMessage()atApp/src/libs/ModifiedExpenseMessage.ts:205-241. But this message is generated by the backend — if it's missing, the backend isn't creating it.Root cause hypotheses (backend — not inspectable from App repo):
RequestMoneyhandler likely ignores or defaults theoperatorfield when evaluating coding rules, always using "contains" semantics regardless of the stored operator. Alternatively, there may be a caching layer for policy rules that serves stale data after an update.MODIFIEDEXPENSEreport action withpolicyRulesModifiedFieldswhen coding rules are applied to new expenses (it may only generate them for retroactive updates viashouldUpdateMatchingTransactions).What changes do you think we should make in order to solve the problem?
Since this is a backend issue, the fix needs to be in the Auth/Web-Expensify server code:
For the match type bug: The backend handler for
RequestMoney(or its post-processing that applies coding rules) needs to be updated to respect theoperatorfield fromCodingRuleFilter. Whenoperatoris'eq', it should require an exact match (case-insensitive) between the transaction merchant andfilters.right. Whenoperatoris'contains', it should check if the merchant string containsfilters.rightas a substring.For the missing system message: The backend should generate a
MODIFIEDEXPENSEreport action withpolicyRulesModifiedFieldswhenever a coding rule is applied to a new expense, not only during retroactive updates. The frontend already has the rendering logic in place atModifiedExpenseMessage.ts:205-241.What alternative solutions did you explore? (Optional)
Investigated whether the matching could be done client-side as a workaround, but this would be architecturally wrong — the backend is the source of truth for rule evaluation, and the system message generation must also happen server-side. Moving matching client-side would create inconsistencies between platforms and bypass server-side validation.
Detailed Investigation
Architecture Overview
Workspace merchant rules are stored as
CodingRuleobjects inpolicy.rules.codingRules(type defined atApp/src/types/onyx/Policy.ts:1720-1756). Each rule has:filters: { left: 'merchant', operator: 'contains' | 'eq', right: '<pattern>' }merchant,category,tag,comment,tax,reimbursable,billableData Flow
AddMatchTypePage.tsx→ stored in form asmatchType→setPolicyCodingRule()buildsfilters.operatorand sendsSetPolicyCodingRuleAPIrequestMoney()→ sendsRequestMoneyAPI with raw expense data → backend evaluates rules → applies matching fields → generatesMODIFIEDEXPENSEreport actionpolicyRulesModifiedFieldsonMODIFIEDEXPENSE→ frontend renders viagetPolicyRulesModifiedMessage()Key Files
App/src/libs/actions/Policy/Rules.ts:123-226- Rule CRUD (correctly sends operator)App/src/types/onyx/Policy.ts:1691-1756- CodingRule type (includes operator in filters)App/src/pages/workspace/rules/MerchantRules/AddMatchTypePage.tsx:41-58- Match type selection UIApp/src/libs/ModifiedExpenseMessage.ts:205-241- System message renderingApp/src/types/onyx/OriginalMessage.ts:837-856- policyRulesModifiedFields typeEvidence Chain
Frontend save →
SetPolicyCodingRuleAPI withoperator: 'eq'→ Backend stores rule → Member creates expense →RequestMoneyAPI → Backend should match using 'eq' semantics but appears to use 'contains' → Backend should generate system message but doesn'tNext Steps for Contributor+ team: This is a backend bug. The fix needs to be in the server-side code that handles
RequestMoneyand evaluates coding rules. The App frontend correctly sends and displays all the necessary data. Reply with@MelvinBot implement thisto create a draft PR (if the fix is in the App repo), or@MelvinBot <your feedback>to refine this analysis.luacmartins commentedon Feb 19, 2026
This is not an issue. The rule is updated correctly, but we also have AgentZero auto-categorizing expenses. So when the user changed the rule to
exactly matchesthe rule no longer applies, but AZ still auto-categorizes the expense asMeals & Entertainmentwhich makes it seem like the rule is being applied.Closing as expected.