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 - "Apply to existing unsubmitted expense" gets disabled when rule is reopened. #82888
Version Number: 9.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):ibellicotest+2250@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Motorola MotoG60 / Android 12 (Hybrid app) - Windows 11 / Chrome App Component: Workspace Settings
Action Performed:
Prerequisite: User is an admin of a workspace.
Prerequisite 2: Rules enabled.
Open the staging.new.expensify.com website.
Navigate to "Workspaces" > "Rules" > "Add Merchant Rule"
In "For expenses with" add any merchant.
In "Apply these updates", add any category, description, tag and "Billable" field "On".
Enable "Apply to existing unsubmitted expenses"
Save the rule.
Open the just created rule.
Note that "Apply to existing unsubmitted expenses" toggle is disabled.
Expected Result:
"Apply to existing unsubmitted expenses" feature should remain enabled when user saves the rule and reopens it.
Actual Result:
"Apply to existing unsubmitted expenses" feature gets disabled after saving merchant rule and reopening the just created rule.
👋 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.
Please re-state the problem that we are trying to solve in this issue.
When a user creates a merchant rule with the "Apply to existing unsubmitted expenses" toggle enabled, saves it, and then reopens the rule for editing, the toggle is always shown as disabled (off). This creates a confusing UX where the user's previously-set preference appears to be lost.
Because it is hardcoded to false, every time the component remounts (i.e., when the user reopens the rule page), the toggle resets to off — regardless of what the user had previously set.
The useEffect block that pre-populates form fields when editing an existing rule (lines 110–130) initializes all other fields from existingRule data but never calls setShouldUpdateMatchingTransactions(...). This means there is no path by which the toggle can be restored to a non-default state on remount.
Additionally, the CodingRule type in src/types/onyx/Policy.ts has no field for shouldUpdateMatchingTransactions, and the setPolicyCodingRule action in src/libs/actions/Policy/Rules.ts never persists this value. As a result, there is no source of truth to restore the toggle state from on reopen.
What changes do you think we should make in order to solve the problem?
Since shouldUpdateMatchingTransactions is semantically a "do this retroactively right now" one-shot action flag (not a persistent rule attribute), the most pragmatic fix that matches user expectations is to default the toggle to true when editing an existing rule, rather than always defaulting to false. This matches the intuition that when a user reopens a rule to edit it, they likely want their changes applied retroactively.
This single change means new rule creation keeps the opt-in behavior (toggle starts off), while editing an existing rule pre-enables the toggle — consistent with the expectation that editing a rule should apply those edits retroactively by default.
What alternative solutions did you explore?
A more complete fix would involve: (1) adding a shouldUpdateMatchingTransactions?: boolean field to the CodingRule type in src/types/onyx/Policy.ts, (2) persisting the value in setPolicyCodingRule() in src/libs/actions/Policy/Rules.ts, and (3) reading it back in the useEffect initialization in MerchantRulePageBase.tsx. However, this approach conflicts with the semantic meaning of the toggle as a one-shot action rather than a persistent rule attribute, adding unnecessary complexity for limited benefit.
Classification: Frontend bug Causing PR: #80545 - "Create merchant rule" by @luacmartins (High confidence) Related Issues: None
Recommendation: ROLL FORWARD
The issue is in the original implementation. The "Apply to existing unsubmitted expenses" toggle is stored in local component state and is not persisted as part of the rule data. When editing an existing rule, the toggle always defaults to false because there is no persisted value to restore.
PR #82438 only enabled merchant rules for all users (removed the production check) but did not introduce this bug. The bug existed from the beginning when merchant rules were first implemented.
Rolling forward with a fix is recommended because:
The fix is straightforward - either persist the toggle value or clarify it as a one-time action in the UI
Labels: No label changes made (keeping DeployBlockerCash since this blocks App deployment)
Detailed Analysis
Evidence
In src/pages/workspace/rules/MerchantRules/MerchantRulePageBase.tsx:
Line 104: const [shouldUpdateMatchingTransactions, setShouldUpdateMatchingTransactions] = useState(false);
Lines 110-130: When editing a rule, the code initializes form fields from existingRule, but does NOT initialize shouldUpdateMatchingTransactions
Lines 397-404: The toggle UI is rendered with the local state value
In src/libs/actions/Policy/Rules.ts:
Line 123: shouldUpdateMatchingTransactions is a parameter passed to the API
Line 223: It is sent as a one-time parameter, not persisted in the rule object
The CodingRule type in src/types/onyx/Policy.ts has no field for storing this value
Verification
The affected files:
/home/runner/_work/App/App/src/pages/workspace/rules/MerchantRules/MerchantRulePageBase.tsx - Contains the toggle UI and state
/home/runner/_work/App/App/src/libs/actions/Policy/Rules.ts - Contains the API call
/home/runner/_work/App/App/src/types/onyx/Policy.ts - Defines the CodingRule type (no field for toggle)
PR #80545 created these files and introduced the toggle functionality on 2026-01-27.
PR #82438 only removed the production check to enable the feature on 2026-02-18.
Root Cause
The toggle value is implemented as ephemeral local state rather than a persisted field. This appears to be a design/implementation oversight where:
The toggle should either be persisted as part of the rule (requires backend changes)
OR clarified in the UI that it only applies when creating/saving the rule
Please re-state the problem that we are trying to solve in this issue.
When a user creates or edits a merchant rule and enables the "Apply to existing unsubmitted expenses" toggle, saves the rule, and then reopens it, the toggle is always shown as disabled/off — the user's selection is not persisted.
What is the root cause of that problem?
The "Apply to existing unsubmitted expenses" toggle is backed by local React state initialized to false on every mount:
This value is sent to the backend as the shouldUpdateMatchingTransactions parameter in the SetPolicyCodingRule API call (Rules.ts:223), but it is never persisted as part of the CodingRule data model. The CodingRule type (Policy.ts:1720-1756) has no field for it, and the edit-mode initialization useEffect (MerchantRulePageBase.tsx:110-130) only restores persisted fields (merchant, category, tag, etc.) — it never sets shouldUpdateMatchingTransactions because there's nothing to read.
So every time the rule page mounts, the toggle defaults to false.
What changes do you think we should make in order to solve the problem?
Important consideration: The label "Apply to existing unsubmitted expenses" reads like a one-time action ("apply this rule retroactively now"), not a persistent rule property. If this is the intended design, the toggle resetting to off on each open is correct behavior — and the fix should be a UX clarification (e.g., wording change, or showing it only on create, not edit).
However, if the intent is for this to be a persistent per-rule setting, then:
Add a shouldUpdateMatchingTransactions (or similar) field to the CodingRule type in src/types/onyx/Policy.ts
Include it in the optimistic Onyx data in setPolicyCodingRule in src/libs/actions/Policy/Rules.ts (the ruleForOnyx object around line 141)
Read it back in the edit-mode useEffect in MerchantRulePageBase.tsx:110-130 to initialize setShouldUpdateMatchingTransactions(existingRule.shouldUpdateMatchingTransactions ?? false)
Ensure the backend persists this field as part of the coding rule and returns it in policy data
The product team should clarify which behavior is intended before implementing a fix.
What alternative solutions did you explore? (Optional)
If this toggle is intended as a one-time action:
Only show the toggle when creating a new rule (not when editing)
Or change the wording to make it clearer it's a one-time action (e.g., "Also apply to existing unsubmitted expenses now")
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.
This is expected. Apply to existing expenses is a toggle that should be manually turned on/off each time you edit a rule since it's a one off event, i.e. we only apply to previously existing expenses when you either create or edit the rule.
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 @dylanexpensify (
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:
twilight2294 commentedon Feb 19, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user creates a merchant rule with the "Apply to existing unsubmitted expenses" toggle enabled, saves it, and then reopens the rule for editing, the toggle is always shown as disabled (off). This creates a confusing UX where the user's previously-set preference appears to be lost.
What is the root cause of that problem?
The toggle state is stored exclusively in local React component state in
src/pages/workspace/rules/MerchantRules/MerchantRulePageBase.tsxat line 104:Because it is hardcoded to
false, every time the component remounts (i.e., when the user reopens the rule page), the toggle resets to off — regardless of what the user had previously set.The
useEffectblock that pre-populates form fields when editing an existing rule (lines 110–130) initializes all other fields fromexistingRuledata but never callssetShouldUpdateMatchingTransactions(...). This means there is no path by which the toggle can be restored to a non-default state on remount.Additionally, the
CodingRuletype insrc/types/onyx/Policy.tshas no field forshouldUpdateMatchingTransactions, and thesetPolicyCodingRuleaction insrc/libs/actions/Policy/Rules.tsnever persists this value. As a result, there is no source of truth to restore the toggle state from on reopen.What changes do you think we should make in order to solve the problem?
Since
shouldUpdateMatchingTransactionsis semantically a "do this retroactively right now" one-shot action flag (not a persistent rule attribute), the most pragmatic fix that matches user expectations is to default the toggle totruewhen editing an existing rule, rather than always defaulting tofalse. This matches the intuition that when a user reopens a rule to edit it, they likely want their changes applied retroactively.In
src/pages/workspace/rules/MerchantRules/MerchantRulePageBase.tsx, line 104, change:This single change means new rule creation keeps the opt-in behavior (toggle starts off), while editing an existing rule pre-enables the toggle — consistent with the expectation that editing a rule should apply those edits retroactively by default.
What alternative solutions did you explore?
A more complete fix would involve: (1) adding a
shouldUpdateMatchingTransactions?: booleanfield to theCodingRuletype insrc/types/onyx/Policy.ts, (2) persisting the value insetPolicyCodingRule()insrc/libs/actions/Policy/Rules.ts, and (3) reading it back in theuseEffectinitialization inMerchantRulePageBase.tsx. However, this approach conflicts with the semantic meaning of the toggle as a one-shot action rather than a persistent rule attribute, adding unnecessary complexity for limited benefit.OSBotify commentedon Feb 19, 2026
Investigation Summary
Classification: Frontend bug
Causing PR: #80545 - "Create merchant rule" by @luacmartins (High confidence)
Related Issues: None
Recommendation: ROLL FORWARD
The issue is in the original implementation. The "Apply to existing unsubmitted expenses" toggle is stored in local component state and is not persisted as part of the rule data. When editing an existing rule, the toggle always defaults to
falsebecause there is no persisted value to restore.PR #82438 only enabled merchant rules for all users (removed the production check) but did not introduce this bug. The bug existed from the beginning when merchant rules were first implemented.
Rolling forward with a fix is recommended because:
Labels: No label changes made (keeping DeployBlockerCash since this blocks App deployment)
Detailed Analysis
Evidence
In
src/pages/workspace/rules/MerchantRules/MerchantRulePageBase.tsx:const [shouldUpdateMatchingTransactions, setShouldUpdateMatchingTransactions] = useState(false);existingRule, but does NOT initializeshouldUpdateMatchingTransactionsIn
src/libs/actions/Policy/Rules.ts:shouldUpdateMatchingTransactionsis a parameter passed to the APIsrc/types/onyx/Policy.tshas no field for storing this valueVerification
The affected files:
/home/runner/_work/App/App/src/pages/workspace/rules/MerchantRules/MerchantRulePageBase.tsx- Contains the toggle UI and state/home/runner/_work/App/App/src/libs/actions/Policy/Rules.ts- Contains the API call/home/runner/_work/App/App/src/types/onyx/Policy.ts- Defines the CodingRule type (no field for toggle)PR #80545 created these files and introduced the toggle functionality on 2026-01-27.
PR #82438 only removed the production check to enable the feature on 2026-02-18.
Root Cause
The toggle value is implemented as ephemeral local state rather than a persisted field. This appears to be a design/implementation oversight where:
MelvinBot commentedon Feb 19, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user creates or edits a merchant rule and enables the "Apply to existing unsubmitted expenses" toggle, saves the rule, and then reopens it, the toggle is always shown as disabled/off — the user's selection is not persisted.
What is the root cause of that problem?
The "Apply to existing unsubmitted expenses" toggle is backed by local React state initialized to
falseon every mount:MerchantRulePageBase.tsx:104—const [shouldUpdateMatchingTransactions, setShouldUpdateMatchingTransactions] = useState(false);This value is sent to the backend as the
shouldUpdateMatchingTransactionsparameter in theSetPolicyCodingRuleAPI call (Rules.ts:223), but it is never persisted as part of theCodingRuledata model. TheCodingRuletype (Policy.ts:1720-1756) has no field for it, and the edit-mode initializationuseEffect(MerchantRulePageBase.tsx:110-130) only restores persisted fields (merchant, category, tag, etc.) — it never setsshouldUpdateMatchingTransactionsbecause there's nothing to read.So every time the rule page mounts, the toggle defaults to
false.What changes do you think we should make in order to solve the problem?
Important consideration: The label "Apply to existing unsubmitted expenses" reads like a one-time action ("apply this rule retroactively now"), not a persistent rule property. If this is the intended design, the toggle resetting to off on each open is correct behavior — and the fix should be a UX clarification (e.g., wording change, or showing it only on create, not edit).
However, if the intent is for this to be a persistent per-rule setting, then:
shouldUpdateMatchingTransactions(or similar) field to theCodingRuletype insrc/types/onyx/Policy.tssetPolicyCodingRuleinsrc/libs/actions/Policy/Rules.ts(theruleForOnyxobject around line 141)useEffectinMerchantRulePageBase.tsx:110-130to initializesetShouldUpdateMatchingTransactions(existingRule.shouldUpdateMatchingTransactions ?? false)The product team should clarify which behavior is intended before implementing a fix.
What alternative solutions did you explore? (Optional)
If this toggle is intended as a one-time action:
Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR, or@MelvinBot <your feedback>to refine this analysis.m-natarajan commentedon Feb 19, 2026
Reproduce, Chrome / v9.3.22-4
Screen.Recording.2026-02-19.at.18.42.35.mp4
luacmartins commentedon Feb 19, 2026
This is expected. Apply to existing expenses is a toggle that should be manually turned on/off each time you edit a rule since it's a one off event, i.e. we only apply to previously existing expenses when you either create or edit the rule.