Skip to content

[Due for payment 2026-06-22] Spend rules - "Spend category" appears for each spend category in the system message #92295

Closed

Description

@applause-bot

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): applausetester+ssndjois2jd1@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.5 / Chrome
App Component: Money Requests

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 one spend category.
  5. Open the created rule.
  6. Edit Spend category and include all spend categories.
  7. Click Save rule.
  8. Go to #admins.
  9. Open the system message for the edit in Step 6.

Expected Result:

"Spend category" will not appear for each spend category in the system message.

Actual Result:

"Spend category" appears for each spend category in the system message.

added allowed spend category 'Alcohol and bars', spend category 'Amazon and bookstores', spend category 'Automotive', spend category 'Car rentals', spend category 'Dining', spend category 'Fuel and gas', spend category 'Government and non-profits', spend category 'Groceries', spend category 'Gyms and fitness', spend category 'Healthcare', spend category 'Hotels', spend category 'Internet and phone', spend category 'Office supplies', spend category 'Parking and tolls', spend category 'Professional services', spend category 'Retail', spend category 'Shipping and delivery', spend category 'Software', spend category 'Transit and rideshare', and spend category 'Travel agencies' 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

Bug7168811_1780331696738.9.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Vincenzo Godoy
Bug ID: 7168811

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. applause-bot commented on Jun 1, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/8b6e0d85b02034e173b3bebc04084e1d36c5a05d288552b1c0e640c3a17873a6

  3. melvin-bot commented on Jun 1, 2026

    @melvin-bot

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

  4. melvin-bot commented on Jun 1, 2026

    @melvin-bot

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

  5. 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.
  6. MelvinBot commented on Jun 1, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    When a spend rule edit adds multiple spend categories at once, the system message is built by emitting one phrase per category and then joining them. The join logic only de-duplicates the repeated adjective ("allowed"), not the repeated noun ("spend category"), so "spend category" is printed before every value.

    Trace for the reported flow (rule edited to allow ~20 categories):

    • getDiffPhrases creates one added phrase per category. Each phrase's body comes from bodySpendCategory, which always renders spend category '<value>'.
    • joinSpendRulePhrases keeps the full body on the first phrase and, for the rest, only swaps bodyWithAdjective → bodyWithoutAdjective. Both variants still contain the words "spend category" — there is no "value-only" variant — so the noun repeats.

    This produces exactly the reported string: added allowed spend category 'Alcohol and bars', spend category 'Amazon and bookstores', ….

    Why it matches, and scope

    actionVerb.allow = allowed, so phrase 1 = added + allowed spend category 'Alcohol and bars'; phrases 2..N reuse bodyWithoutAdjective = spend category '<value>'; formatList joins them and composeOnCards appends on 'mmmoo'.

    The same latent bug applies to merchants (bodyMerchant) — adding multiple merchants would read merchant 'A', merchant 'B', …. This is purely a client-side display formatting bug in App; the backend just sends the category list.

    What changes do you think we should make in order to solve the problem?

    Make a repeated noun collapse to just the quoted value for consecutive phrases of the same kind. Concretely, in SpendRuleChangeLogUtils.ts:

    1. Add to SpendRulePhrase a noun discriminator (e.g. 'merchant' | 'spendCategory' | '') and a value-only body (e.g. 'Amazon and bookstores'), populated in getDiffPhrases.
    2. In joinSpendRulePhrases, when the current phrase's noun matches the previously-appended phrase's noun, push the value-only body instead of bodyWithoutAdjective.

    Result: added allowed spend category 'Alcohol and bars', 'Amazon and bookstores', … and 'Travel agencies' on 'mmmoo' — and the same fix covers merchants.

    What alternative solutions did you explore? (Optional)

    In getDiffPhrases, collapse multiple added/removed values of the same kind into a single phrase whose body lists all values (e.g. allowed spend category 'A', 'B', 'C'). Cleaner output, but needs a value-list string that doesn't re-wrap each value in quotes.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/92295) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.

  7. luacmartins commented on Jun 1, 2026

    @luacmartins
    Contributor

    NAB this feature is staging only

  8. 14 remaining items

  9. melvin-bot commented on Jun 15, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  10. FitseTLT commented on Jun 16, 2026

    @FitseTLT
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment:https://github.com/Expensify/App/pull/89561/changes#r3421072488

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion:

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Precondition:

    • Control workspace with Rules enabled

    Test:

    1. Create a spend rule with one spend category
    2. Edit the rule to include all spend categories
    3. Save and open the system message in #admins
    4. Verify the message shows added allowed spend category 'X', 'Y', 'Z'... without repeating "spend category"
    5. Verify the same behavior when adding multiple merchants at once
    6. Verify the same behavior when adding and removing multiple merchants and categories respectively.

    Do we agree 👍 or 👎

  11. melvin-bot commented on Jun 19, 2026

    @melvin-bot

    ⚠️ Looks like this issue was linked to a Deploy Blocker here

    If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

    If a regression has occurred and you are the assigned CM follow the instructions here.

    If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

  12. FitseTLT commented on Jun 19, 2026

    @FitseTLT
    Contributor

    ⚠️ Looks like this issue was linked to a Deploy Blocker here

    If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

    If a regression has occurred and you are the assigned CM follow the instructions here.

    If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

    False alarm

  13. melvin-bot commented on Jun 21, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    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 22, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @FitseTLT due $250 via NewDot

    ^ Test case created. Thx

  15. m-natarajan commented on Jun 22, 2026

    @m-natarajan

    @FitseTLT Spend category not displayed in Edit rule. Tried both expensifail account and public doamin as well. Is this an issue or option N/A?

    Image
  16. flaviadefaria commented on Jul 31, 2026

    @flaviadefaria
    Contributor

    Approved: @FitseTLT due $250 via NewDot

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