Skip to content

[Due for payment 2026-06-18] Spend rule - System message thread header shows "max amount from $100 to $100" after changing restriction #92293

Closed

Description

@vincdargento

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.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.
  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Rules.
  3. Click Add spend rule.
  4. Create a spend rule with Max amount.
  5. Open the created rule.
  6. Change the Restriction type from Allow to Block.
  7. Click Save rule.
  8. Go to #admins.
  9. 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'".

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Screen.Recording.2026-06-01.at.6.08.44.PM.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 1, 2026
  2. melvin-bot commented on Jun 1, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #89561

  3. melvin-bot commented on Jun 1, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  4. github-actions commented on Jun 1, 2026

    @github-actions
    Contributor

    👋 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:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  5. OSBotify commented on Jun 1, 2026

    @OSBotify
    Contributor

    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.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.

    Detailed Analysis

    Evidence

    • melvin-bot already identified PR Add policy change log #89561 as the causing 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.

  6. MelvinBot commented on Jun 1, 2026

    @MelvinBot
    Contributor

    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.

    • 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:

    • 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_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.

  7. 13 remaining items

  8. melvin-bot commented on Jun 11, 2026

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  9. melvin-bot commented on Jun 11, 2026

    @melvin-bot

    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:

    • @truph01 requires payment through NewDot Manual Requests
  10. melvin-bot commented on Jun 11, 2026

    @melvin-bot

    @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]

  11. melvin-bot commented on Jun 15, 2026

    @melvin-bot

    @truph01 Whoops! This issue is 2 days overdue. Let's get this updated quick!

  12. melvin-bot commented on Jun 15, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  13. melvin-bot commented on Jun 17, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    • Reviewer: @truph01 owed $250 via NewDot

    BugZero Checklist (@mallenexpensify)

    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants//hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  14. mallenexpensify commented on Jun 19, 2026

    @mallenexpensify
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2Engineering

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions