Skip to content

[$175] The "Create a rule" banner doesn't appears on the second expense creation #106596

Open

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.5.36-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #103042
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Windows 11 / Chrome, iPhone 13 / iOS 27 Beta, Samsung Galaxy A52 / Android 14
App Component: Money Requests

Action Performed:

Preconditions: sign up to a new gmail account without +, and create a control workspace & enable rules

Steps:

  1. Create an expense, set merchant to "M2" and category to "Coffee" (add new category in confirmation page)
  2. Create the second expense with the same merchant & category as the first expense, observe the confirmation page

Expected Result:

The "Create a rule" banner appears on the second expense creation

Actual Result:

The "Create a rule" banner doesn't appear on the second expense creation

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7310725_1794362787361.bandicam_2026-11-11_08-57-22-279.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Chandana Kiran
Bug ID: 7310725

Upwork Automation - Do Not Edit

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Nov 11, 2026
  2. applause-bot commented on Nov 11, 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/5188af907caa8a091a0fcd330754ce0c879aeb07899ea60864804076202fd065

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Nov 11, 2026
  4. melvin-bot commented on Nov 11, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @thelullabyy (External)

  5. changed the title [-]The "Create a rule" banner doesn't appears on the second expense creation[/-] [+][$175] The "Create a rule" banner doesn't appears on the second expense creation[/+] on Nov 11, 2026
  6. melvin-bot commented on Nov 11, 2026

    @melvin-bot
  7. MelvinBot commented on Nov 11, 2026

    @MelvinBot
    Contributor

    🤖 Web test steps verification results: ⚠️ partial

    Verified first-expense creation on web, but an interaction blocker prevented testing either banner assertion. The available account used an aliased Gmail address, unlike the issue’s requested fixture.

    Second expense verification blocked

    Step Status
    Create the first expense in a Control workspace with Rules enabledCreated a fresh-merchant expense with Coffee selected during creation. Workspace and expense values were confirmed by read-back.
    First expense created; final menu state
    ✅
    Create the second matching expense and inspect its confirmation pageBlocked: the automation could not activate Create expense because a dialog covered the target. This is not evidence of a product banner failure.
    Second expense verification blocked
    ⚠️
    Compare banners after the first and second matching edits to saved expensesNot reached. Neither banner assertion was performed.
    ⚠️
    Structured analysis — medium confidence

    Proposal

    What is the root cause of that problem?

    The written reproduction selects categories during creation, but the implemented suggestion flow tracks edits to saved expenses. This explains the missing banner in code; an App regression has not been established.

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

    Clarify the QA steps before proposing a code fix. Using a fresh merchant, create two expenses first, then reopen each and change its category to Coffee. Check the banner after the second saved-expense edit.

    The PR’s test plan explicitly describes this sequence in test 1, but abbreviates it ambiguously in test 2. If creation-time suggestions are intended, product confirmation is needed: that behavior is not currently implemented.

    What alternative solutions did you explore?

    A missing server confirmation could explain failure after saved-expense edits, but cannot explain away the creation-path distinction. The supported edit flow remains unverified in the browser.

    The two relevant unit suites passed: 44 tests. These cover category routing and suggestion gates, not live server behavior.

    Related issue: Support better rule creation suggestions describes repeated transaction updates rather than initial creation.


    view run · view recording

  8. HindsightWise commented on Nov 11, 2026

    @HindsightWise

    Contributor details
    Your Expensify account email: hindsightwise@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~013d295f05a578824b

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    In a Control workspace with Rules enabled, creating a second expense with the same merchant ("M2") and category ("Coffee") as a previously created expense does not show the "Create a rule" banner on the confirmation page during the expense creation flow.

    What is the root cause of that problem?

    The "Create a rule" suggestion banner was architected and implemented in PR #103042 to track post-creation edits made to existing saved expenses, not initial field selections made on the expense creation confirmation page. Specifically:

    1. Category selection during creation is a draft update, not a tracked edit:

      • On the confirmation page (IOURequestStepConfirmation), selecting or adding a category invokes useUpdateTransactionCategory (src/hooks/useUpdateTransactionCategory.ts:92–129).
      • Because isEditing is false during the initial money request creation flow, updateCategory executes setMoneyRequestCategory, updating only the local draft transaction in Onyx.
      • It does not call updateMoneyRequestCategory, does not dispatch an UpdateMoneyRequest API write to the backend, and never calls trackMerchantRuleSuggestion (src/libs/actions/MerchantRuleSuggestion.ts:47).
    2. Server-side pattern confirmation is tied to UpdateMoneyRequest:

      • Under PR Gate the merchant rule suggestion on the server's edit count #103042, the server evaluates rolling 30-day repeat patterns only in response to UpdateMoneyRequest commands, returning suggestNewRuleCreation_<transactionID>: {category: true} as onyxData.
      • The backend CreateMoneyRequest command does not currently evaluate or return suggestNewRuleCreation_<transactionID>.
      • Under MerchantRuleSuggestionUtils.isMerchantRuleSuggestionLive and getOfferableMerchantRuleSuggestionFields (src/libs/MerchantRuleSuggestionUtils.ts:23–49), a banner can only mount when both client-side editedFields and server-side confirmation exist.
    3. Banner UI lifecycle and mount location:

      • MerchantRuleSuggestionBanner (src/components/MerchantRuleSuggestionBanner.tsx) is only rendered in ReportFooter.tsx and ReportActionsListContent.tsx (the report chat and transaction thread views). It is not mounted in MoneyRequestConfirmationList.tsx or IOURequestStepConfirmation.tsx.
    4. QA test plan misunderstanding:

      • In PR Gate the merchant rule suggestion on the server's edit count #103042, Test 1 explicitly specified:
        1. Create two submitted expenses with merchant M1.
        2. Open the first and set its category to Coffee. No banner. One edit is not a pattern.
        3. Open the second and set its category to Coffee. The "Create a rule" banner slides in.
      • Test 2 condensed this description:
        1. Create two M2 expenses and set both categories to Coffee. The banner appears on the second.
      • The QA tester interpreted Test 2 as setting the category on the confirmation page during initial expense creation, rather than creating the expenses first and subsequently updating their categories.

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

    Depending on Product intent, there are two distinct paths:

    Option A: Clarify QA steps and close as Expected Behavior / NAB (Recommended)

    If merchant rule suggestions are intended to guide users who repeatedly edit existing saved expenses (as established in PR #103042 and Issue #101504):

    • Clarify the QA reproduction steps:
      1. Create two expenses under merchant M2 in a Control workspace with Rules enabled.
      2. Open the first saved expense and update its category to Coffee. No banner appears (1 edit is not a pattern).
      3. Open the second saved expense and update its category to Coffee. The "Create a rule" banner slides in above the report composer.
    • Close this issue as Expected Behavior.

    Option B: Extend Merchant Rule Suggestions to initial expense creation

    If Product confirms that rule suggestions should also trigger during the initial expense creation flow:

    1. Server-side (Auth / Web-Secure):
      • Update CreateMoneyRequest backend handling to inspect the rolling 30-day merchant/category pattern and include suggestNewRuleCreation_<transactionID> in the CreateMoneyRequest response onyxData.
    2. Client-side tracking (src/libs/actions/IOU/MoneyRequest.ts):
      • When submitting the request in requestMoney, if the expense has a merchant and category/tag/tax set, call trackMerchantRuleSuggestion with the newly generated transactionID and target reportID.
    3. Client UI (src/pages/iou/request/step/IOURequestStepConfirmation.tsx):
      • Mount MerchantRuleSuggestionBanner inside MoneyRequestConfirmationList or ensure it smoothly displays upon navigating to the created transaction thread once the server response confirms the pattern.

    What alternative solutions did you explore? (Optional)

    1. Tracking draft category picks locally without server confirmation:

    What automated tests can you add to prevent this from re-occurring?

    In tests/unit/useUpdateTransactionCategoryTest.ts:

    • Add a unit test verifying that isDraftUpdate is true during the money request creation flow (isEditing = false) and that draft category updates do not invoke trackMerchantRuleSuggestion or updateMoneyRequestCategory.
      In tests/unit/MerchantRuleSuggestionUtilsTest.ts:
    • Add a test verifying that isMerchantRuleSuggestionLive returns false when suggestNewRuleCreation_<transactionID> is absent or contains no confirmed fields.

    — submitted with Antigravity on the contributor's behalf

  9. melvin-bot commented on Nov 11, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  10. kevinjosh10 commented on Nov 11, 2026

    @kevinjosh10

    Proposal

    What is the root cause of that problem?

    When I investigated the codebase and PR history, I found this issue is an Applause QA test execution misunderstanding of PR #103042; the app is functioning exactly as designed under the architectural specifications established in PR #103042 and parent Issue #101504.

    Specifically, there are 4 architectural reasons why the banner does not (and should not) appear on the expense creation confirmation page:

    1. Category selection during creation is a draft update, not a tracked edit

    • On the confirmation page (IOURequestStepConfirmation), selecting or creating a category routes through useUpdateTransactionCategory.
    • Because isEditing is false during expense creation (isExistingExpenseUpdate = !isSplitUpdate && isEditing && !!transaction && !!report), updateCategory executes setMoneyRequestCategory (useUpdateTransactionCategory.ts:129).
    • This only mutates the client-side draft transaction in Onyx (transactionDraft_${transactionID}). It does not call updateMoneyRequestCategory, does not send an UpdateMoneyRequest API write to the backend, and never dispatches trackMerchantRuleSuggestion (src/libs/actions/MerchantRuleSuggestion.ts:56).

    2. Dual-Gating: Server pattern confirmation is coupled to UpdateMoneyRequest

    • Under Issue #101504, the feature was specifically designed to count repeats when users update saved transactions:

      "The popup visibility will be mandated by a suggestNewRuleCreation response field in the UpdateMoneyRequest or UpdateMoneyRequestVendor command."

    • In PR #103042, Auth counts how often the same workspace, merchant, field, and value are edited over a rolling 30-day window on UpdateMoneyRequest, returning:
      "suggestNewRuleCreation_<transactionID>": {"category": true}
    • Under MerchantRuleSuggestionUtils.isMerchantRuleSuggestionLive and getOfferableMerchantRuleSuggestionFields, a suggestion is live only when both conditions are satisfied:
      1. The client has locally recorded the edit in RAM_ONLY_MERCHANT_RULE_SUGGESTION.
      2. The server confirms the 30-day pattern via suggestNewRuleCreation_<transactionID>.
    • The CreateMoneyRequest backend command does not evaluate or return suggestNewRuleCreation_<transactionID>.

    3. Banner Mount Points and UI Lifecycle

    • MerchantRuleSuggestionBanner is mounted exclusively in:
    • It is not rendered anywhere in IOURequestStepConfirmation or the confirmation list components.
    • Furthermore, useMerchantRuleSuggestion.ts:49-57 requires a valid reportID hosting the saved transaction. On the confirmation page, the transaction has not been submitted yet and no report thread exists.

    4. The QA Reproduction Misinterpreted PR #103042 Test 2

    In the Test Plan of PR #103042, Test 1 and Test 2 were specified as follows:

    Test in PR #103042 Steps Specified in PR #103042 What QA Performed in #106596
    Test 1 (M1) 1. Create two submitted expenses with merchant M1.
    2. Open the first and set its category to Coffee. No banner.
    3. Open the second and set its category to Coffee. The banner appears.
    N/A
    Test 2 (M2) "Create two M2 expenses and set both categories to Coffee. The banner appears on the second. The same value under a new merchant starts a fresh count." QA set the category on the confirmation page during initial expense creation, rather than creating the expenses first and subsequently updating their categories as detailed in Test 1.

    Test 2 was written as a concise restatement of Test 1 for a fresh merchant (M2). QA read Test 2 literally and attempted to trigger rule suggestions during initial expense creation, which was never the scope of PR #103042 or Issue #101504.


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

    Primary Recommendation: Clarify QA Test Steps and Close as Expected Behavior / NAB

    Because the design intent of Issue #101504 and PR #103042 was specifically to prevent annoying users during creation and only suggest rules when they repeatedly edit/correct transactions after submission, I recommend closing this issue as Expected Behavior.

    Corrected Verification Steps for QA:

    1. In a Control workspace with Rules enabled, create two submitted expenses with merchant M2 (with any initial category or no category).
    2. Open the first expense and update its category to Coffee.
      • Result: No banner appears (1 edit is not a pattern).
    3. Open the second expense and update its category to Coffee.
      • Result: The "Create a rule" banner slides in above the report composer / in the transaction thread as expected.

    Alternative Implementation (If Product wants Rule Suggestions during Creation Flow)

    If Product confirms that rule suggestions should also be surfaced during the initial expense creation flow, here is how I will implement it:

    1. Backend (Auth / Web-Secure):
      • Update CreateMoneyRequest to evaluate the 30-day merchant/field frequency and return ONYXKEYS.COLLECTION.SUGGEST_NEW_RULE_CREATION in the response onyxData if the threshold is met.
    2. Client Actions (src/libs/actions/IOU/MoneyRequest.ts):
      • In requestMoney, record the pending rule suggestion via trackMerchantRuleSuggestion using the newly generated transactionID and target reportID.
    3. Client UI (src/pages/iou/request/step/IOURequestStepConfirmation/index.tsx):
      • Render MerchantRuleSuggestionBanner inside IOURequestStepConfirmation (e.g., above the footer submission button), or allow the banner to smoothly display upon navigating to the created report thread after the response lands.

    What alternative solutions did you explore? (Optional)

    • Triggering suggestions locally on draft selections without server confirmation:
      • Why I rejected this: Client-side draft state lacks visibility into workspace-wide transaction history over a rolling 30-day window. Evaluating suggestions on draft state alone would re-introduce the exact bug PR Gate the merchant rule suggestion on the server's edit count #103042 solved: showing false-positive rule prompts on one-off creations.

    What automated tests can you add to prevent this from re-occurring?

    1. tests/unit/useUpdateTransactionCategoryTest.ts:
      • I will add a unit test verifying that when isEditing is false (creation flow), isDraftUpdate is true, setMoneyRequestCategory is called, and updateMoneyRequestCategory / trackMerchantRuleSuggestion is not invoked.
    2. tests/unit/MerchantRuleSuggestionUtilsTest.ts:
      • I will add a test verifying isMerchantRuleSuggestionLive returns false when suggestNewRuleCreation_<transactionID> is missing or contains no matching confirmed fields.

    Contributor details

    Your Expensify account email: lkevinjosh10@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374

  11. melvin-bot commented on Nov 11, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  12. TassioSales commented on Nov 11, 2026

    @TassioSales

    Contributor details
    Your Expensify account email: tassiolucian.ljs@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~0179cdc82689f205c7

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When a user creates their second expense in a workspace, the "Create a rule" educational banner does not appear, even though workspace rule creation criteria are met.

    What is the root cause of that problem?

    In src/libs/ReportUtils.ts (shouldShowCreateRuleBanner):
    The condition evaluating whether to surface the rule banner checks an overly restrictive threshold or increments the dismissed count counter during the first expense creation cycle prematurely. When the second expense transaction is created, the dismissed/shown flag in Onyx (NVP_CREATE_RULE_BANNER_SHOWN) evaluates as already consumed, suppressing the banner.

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

    1. In src/libs/ReportUtils.ts:
      • Refactor shouldShowCreateRuleBanner to correctly check the workspace expense count threshold (displaying when the user creates eligible consecutive expenses before a rule is configured).
      • Ensure dismissal tracking is only triggered on explicit user dismissal or when a rule is successfully created, not by passive expense creation.

    What alternative solutions did you explore? (Optional)

    Always showing the banner regardless of expense count, but that causes user fatigue.

    Automated Tests

    Add unit test in tests/unit/ReportRulesBannerTest.ts:

    • Verify shouldShowCreateRuleBanner returns true on the second expense creation when no rules exist and banner was not explicitly dismissed.
    • Verify banner is suppressed once explicitly dismissed.
  13. melvin-bot commented on Nov 11, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

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

Metadata

Metadata

Assignees

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorOverdue

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions