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
[Due for payment 2026-06-18] Spend rule - System message thread header shows "max amount from $100 to $100" after changing restriction #92293
Version Number: 9.3.90-2 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:#89561 Email or phone of affected tester (no customers): changed spend rule from only allow to block on 'mmmoo' Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Mac 26.5 / Chrome App Component: Workspace Settings
Action Performed:
Precondition:
Enable Rules and Expensify Card.
Workspace has at least one Expensify card.
Go to staging.new.expensify.com
Go to workspace settings > Rules.
Click Add spend rule.
Create a spend rule with Max amount.
Open the created rule.
Change the Restriction type from Allow to Block.
Click Save rule.
Go to #admins.
Open the system message "changed spend rule from only allow to block on 'mmmoo'" in thread.
Expected Result:
System message thread header should match the system message - changed spend rule from only allow to block on 'mmmoo'.
Actual Result:
System message thread header shows "changed spend rule from only allow to block and max amount from $100 to $100 on 'mmmoo'", while the system message is "changed spend rule from only allow to block on 'mmmoo'".
👋 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: #89561 - "Add policy change log" by @luacmartins (High confidence) Related Issues: #86527
Recommendation: REVERT
PR #89561 introduced SpendRuleChangeLogUtils.ts which contains a bug in the computeSpendRuleAmountDiff function. When a spend rule's restriction type is changed (e.g., allow to block) while the max amount stays the same, the function can incorrectly detect an amount change because the sameAmount check (getSpendRuleValueInCents) only compares the numeric value but not the amount operator. If the operator changes when switching restriction types (e.g., from <= to >), the amounts are treated as different, producing "max amount from $100 to $100" in the message even though the displayed values are identical. This causes the thread header to diverge from the system message shown in the chat.
Assigned: @luacmartins (PR author), @cead22 and @truph01 (approving reviewers) Labels: No label changes — DeployBlockerCash is appropriate and kept; the issue is staging-only (new feature not in production), caused by an App PR.
PR Add policy change log #89561 introduced src/libs/SpendRuleChangeLogUtils.ts and the getUpdateExpensifyCardRuleMessage function, which is exactly the code path generating the thread header message
The bug is staging-only and this is a new feature (spend rule change logs), which matches that the feature does not exist in production
The PR was merged 2026-05-29 and the issue was reported for version 9.3.90-2, consistent with the StagingDeployCash timeline
Verification
The affected file is src/libs/SpendRuleChangeLogUtils.ts, introduced entirely by PR Add policy change log #89561
PolicyChangeLogContent.tsx (also modified by PR Add policy change log #89561) routes UPDATE_EXPENSIFY_CARD_RULE actions to getUpdateExpensifyCardRuleMessage, which generates the thread header text
SidebarUtils.ts (also modified by PR Add policy change log #89561) uses the same function for the alternate text shown in the conversation list
Root Cause
In computeSpendRuleAmountDiff (lines 105-125 of SpendRuleChangeLogUtils.ts), the sameAmount check at line 117 only compares the numeric value in cents via getSpendRuleValueInCents, but does not compare the operator field. When the restriction type changes from "allow" to "block", the backend may update the amount operator (e.g., from <= to >) while keeping the value at $100. Because the operators differ, sameAmount evaluates to false, causing the function to return added: [newAmount], removed: [oldAmount]. Both amounts display as "$100", producing the erroneous "max amount from $100 to $100" phrase in the thread header. This causes the thread header to show a longer, incorrect message compared to the simpler system message in the chat.
The chat system message and the thread header are generated by two different code paths, and PR #89561 only wired the new client-side renderer into the former.
Chat body is rendered by PolicyChangeLogContent.tsx:168, which calls the new getUpdateExpensifyCardRuleMessage. That function compares only the amount value (SpendRuleChangeLogUtils.ts:117-120), sees $100 → $100 as unchanged, and correctly omits the amount → "changed spend rule from only allow to block on 'mmmoo'".
Thread header comes from getReportName → computeReportNameBasedOnReportAction, which has a case for almost every POLICY_CHANGE_LOG type but none for the EXPENSIFY_CARD_RULE types. It therefore falls through to ReportNameUtils.ts:792 and renders the raw backend message.html, which still contains the spurious "max amount from $100 to $100" (the backend treats the allow→block operator flip as an amount change).
So the new client renderer "fixes" the message everywhere it's wired in (chat body, LHN, clipboard) but the thread header was never wired in, so it shows the old backend string.
What changes do you think we should make in order to solve the problem?
Add the three missing EXPENSIFY_CARD_RULE cases to computeReportNameBasedOnReportAction in src/libs/ReportNameUtils.ts, right alongside the existing card-feed cases (ReportNameUtils.ts:760-783), returning the corresponding client-rendered message:
This makes the thread header use the same client renderer as the chat body, so the two stay consistent. This is exactly the pattern every other custom POLICY_CHANGE_LOG type already follows.
What alternative solutions did you explore? (Optional)
Fixing the backend so the stored message.html doesn't report an amount change when only the restriction flipped. That's a legitimate secondary bug, but the App feature's design is to render these messages client-side from the structured originalMessage, so the App-side fix above is the correct and complete fix for the user-visible inconsistency (and doesn't require a backend deploy).
Evidence chain
The client renderer cannot produce "from $100 to $100": computeSpendRuleAmountDiff returns an empty diff when the value is unchanged (SpendRuleChangeLogUtils.ts:117-120). A "from X to Y" phrase requires added.length === 1 && removed.length === 1, which only happens when the cents differ — and different cents would render as different dollar amounts. So the buggy text can only come from the raw backend string.
Thread-header path confirmed: HeaderView.tsx → getReportName → computeReportNameBasedOnReportAction (no EXPENSIFY_CARD_RULE case, returns undefined at line 792) → computeChatThreadReportName → getReportActionText(parentReportAction) which returns Parser.htmlToText(message.html || message.text).
getUpdateExpensifyCardRuleMessage is imported only by PolicyChangeLogContent.tsx, SidebarUtils.ts, and ContextMenuActions.tsx — never by ReportNameUtils.ts.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/92293) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.4.5-6 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
@truph01 The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]
Activity
melvin-bot commentedon Jun 1, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #89561
melvin-bot commentedon Jun 1, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Jun 1, 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 Jun 1, 2026
Investigation Summary
Classification: Frontend bug
Causing PR: #89561 - "Add policy change log" by @luacmartins (High confidence)
Related Issues: #86527
Recommendation: REVERT
PR #89561 introduced
SpendRuleChangeLogUtils.tswhich contains a bug in thecomputeSpendRuleAmountDifffunction. When a spend rule's restriction type is changed (e.g., allow to block) while the max amount stays the same, the function can incorrectly detect an amount change because thesameAmountcheck (getSpendRuleValueInCents) only compares the numeric value but not the amount operator. If the operator changes when switching restriction types (e.g., from<=to>), the amounts are treated as different, producing "max amount from $100 to $100" in the message even though the displayed values are identical. This causes the thread header to diverge from the system message shown in the chat.Assigned: @luacmartins (PR author), @cead22 and @truph01 (approving reviewers)
Labels: No label changes —
DeployBlockerCashis appropriate and kept; the issue is staging-only (new feature not in production), caused by an App PR.Detailed Analysis
Evidence
src/libs/SpendRuleChangeLogUtils.tsand thegetUpdateExpensifyCardRuleMessagefunction, which is exactly the code path generating the thread header messageVerification
src/libs/SpendRuleChangeLogUtils.ts, introduced entirely by PR Add policy change log #89561PolicyChangeLogContent.tsx(also modified by PR Add policy change log #89561) routesUPDATE_EXPENSIFY_CARD_RULEactions togetUpdateExpensifyCardRuleMessage, which generates the thread header textSidebarUtils.ts(also modified by PR Add policy change log #89561) uses the same function for the alternate text shown in the conversation listRoot Cause
In
computeSpendRuleAmountDiff(lines 105-125 ofSpendRuleChangeLogUtils.ts), thesameAmountcheck at line 117 only compares the numeric value in cents viagetSpendRuleValueInCents, but does not compare theoperatorfield. When the restriction type changes from "allow" to "block", the backend may update the amount operator (e.g., from<=to>) while keeping the value at $100. Because the operators differ,sameAmountevaluates tofalse, causing the function to returnadded: [newAmount], removed: [oldAmount]. Both amounts display as "$100", producing the erroneous "max amount from $100 to $100" phrase in the thread header. This causes the thread header to show a longer, incorrect message compared to the simpler system message in the chat.MelvinBot commentedon Jun 1, 2026
Proposal
What is the root cause of that problem?
The chat system message and the thread header are generated by two different code paths, and PR #89561 only wired the new client-side renderer into the former.
PolicyChangeLogContent.tsx:168, which calls the newgetUpdateExpensifyCardRuleMessage. That function compares only the amount value (SpendRuleChangeLogUtils.ts:117-120), sees$100 → $100as unchanged, and correctly omits the amount → "changed spend rule from only allow to block on 'mmmoo'".getReportName→computeReportNameBasedOnReportAction, which has a case for almost everyPOLICY_CHANGE_LOGtype but none for theEXPENSIFY_CARD_RULEtypes. It therefore falls through toReportNameUtils.ts:792and renders the raw backendmessage.html, which still contains the spurious "max amount from $100 to $100" (the backend treats the allow→block operator flip as an amount change).So the new client renderer "fixes" the message everywhere it's wired in (chat body, LHN, clipboard) but the thread header was never wired in, so it shows the old backend string.
What changes do you think we should make in order to solve the problem?
Add the three missing
EXPENSIFY_CARD_RULEcases tocomputeReportNameBasedOnReportActioninsrc/libs/ReportNameUtils.ts, right alongside the existing card-feed cases (ReportNameUtils.ts:760-783), returning the corresponding client-rendered message:ADD_EXPENSIFY_CARD_RULE→getAddExpensifyCardRuleMessage(translate, parentReportAction)UPDATE_EXPENSIFY_CARD_RULE→getUpdateExpensifyCardRuleMessage(translate, parentReportAction)REMOVE_EXPENSIFY_CARD_RULE→getRemoveExpensifyCardRuleMessage(translate, parentReportAction)This makes the thread header use the same client renderer as the chat body, so the two stay consistent. This is exactly the pattern every other custom
POLICY_CHANGE_LOGtype already follows.What alternative solutions did you explore? (Optional)
Fixing the backend so the stored
message.htmldoesn't report an amount change when only the restriction flipped. That's a legitimate secondary bug, but the App feature's design is to render these messages client-side from the structuredoriginalMessage, so the App-side fix above is the correct and complete fix for the user-visible inconsistency (and doesn't require a backend deploy).Evidence chain
computeSpendRuleAmountDiffreturns an empty diff when the value is unchanged (SpendRuleChangeLogUtils.ts:117-120). A "from X to Y" phrase requiresadded.length === 1 && removed.length === 1, which only happens when the cents differ — and different cents would render as different dollar amounts. So the buggy text can only come from the raw backend string.HeaderView.tsx→getReportName→computeReportNameBasedOnReportAction(noEXPENSIFY_CARD_RULEcase, returnsundefinedat line 792) →computeChatThreadReportName→getReportActionText(parentReportAction)which returnsParser.htmlToText(message.html || message.text).getUpdateExpensifyCardRuleMessageis imported only byPolicyChangeLogContent.tsx,SidebarUtils.ts, andContextMenuActions.tsx— never byReportNameUtils.ts.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/92293)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
13 remaining items
melvin-bot commentedon Jun 11, 2026
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Jun 11, 2026
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.4.5-6 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2026-06-18. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Jun 11, 2026
@truph01 The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]
melvin-bot commentedon Jun 15, 2026
@truph01 Whoops! This issue is 2 days overdue. Let's get this updated quick!
melvin-bot commentedon Jun 15, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Jun 17, 2026
Payment Summary
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Jun 19, 2026
Closing as not needed payment cuz it appears to be a regression and @truph01 worked on the offending PR. Comment or reopen if you disagree.