Skip to content

[Due for payment 2026-10-07] [$175] [Exploratory] Rules - Save rule button loads infinitely after saving empty values #100194

Closed

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.4.66-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: #99655
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: Workspace Settings

Action Performed:

Precondition:

  • Log in with Expensifail account.
  • Enable Rules.
  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Rules > Flag for review.
  3. Click Create flag rule.
  4. Without entering anything, click Save rule.

Expected Result:

Save rule button will not load infinitely after saving empty values.

Actual Result:

Save rule button loads infinitely after saving empty values.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7249196_1788362756058.9.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7249196

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit

Activity

  1. applause-bot commented on Sep 2, 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/4a66e85f840482c634de7dfafb51fcb506bdcc85287fe9b3d782e265b5d84429

  2. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 24, 2026
  3. MelvinBot commented on Sep 24, 2026

    @MelvinBot
    Contributor

    Proposal

    Reproduced on web against current main (e029fad): the spinner is still going 10s after the click, the button is disabled, and further clicks do nothing — while the validation errors render correctly underneath.

    Save rule button still spinning 10 seconds after clicking Save with empty values, with validation errors shown

    What is the root cause of that problem?

    FormAlertWithSubmitButton shows a spinner on every press unless the caller opts out, and the Flag for review page never opts out.

    The button's shouldShowLoadingImmediatelyOnPress prop defaults to true, so the press is routed through startWithLoading(onSubmit). That sets isPressed = true in usePressLoading, which only ever clears it in three ways: an external isLoading flips true, the handler throws, or the screen regains focus.

    None of those happen here. FlagForReviewRulePageBase.handleSubmit validates, calls setShouldShowError(true), and returns — no navigation, no throw — and the page passes no isLoading to the button. So isPressed stays true forever.

    The prop's own JSDoc says to set it to false "when onSubmit only changes local state", and the sibling rule pages (Merchant, Spend, Require fields) all do exactly that. Flag for review was simply missed.

    Second instance of the same bug: MerchantTypeRulePageBase has a byte-identical handleSubmit and also omits the opt-out, so "Merchant type" > Save rule with an empty category spins forever too.

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

    Add shouldShowLoadingImmediatelyOnPress={false} to the FormAlertWithSubmitButton on both affected pages:

    1. FlagForReviewRulePageBase.tsx:205-215
    2. MerchantTypeRulePageBase.tsx:137-147

    This matches what the other four rule pages already do. The save path itself is synchronous and navigates away, so nothing is lost by dropping the optimistic spinner.

    What alternative solutions did you explore? (Optional)

    Alternatives considered and evidence

    Alternative A — clear isPressed after the handler returns. In usePressLoading, reset isPressed in a finally rather than only on catch. This fixes every current and future instance at once, but it also kills the optimistic spinner for the intended case: a handler that kicks off a slow Onyx write and navigates. Would need to distinguish "returned without doing async work" from "returned having started async work", which the hook can't see. Rejected as too broad for a bug fix, though worth considering separately.

    Alternative B — validate before showing the spinner. Have FormAlertWithSubmitButton skip startWithLoading when isAlertVisible is already true. Doesn't work: on the first press shouldShowError is still false, so the alert isn't visible yet.

    Alternative C — disable the button while invalid. Rejected; Expensify's pattern is to let the user press and then surface the inline error, which this page already does correctly.

    How it got here. usePressLoading and the default-true prop both arrived in Introduce the spinner on the FormAlertWithSubmitButton buttons (merged 2026-07-13), which hand-picked the pages that opt out. FlagForReviewRulePageBase.tsx and MerchantTypeRulePageBase.tsx both landed on main on 2026-06-26, after that PR's branch was cut, so neither made the opt-out list. Add a "Then" section to the Flag for review rule editor, cited in the report, only added the "Then do the following" section and did not cause this.

    Verification. Reproduced end to end on web: enabled Rules on a workspace, went to Rules > Flag for review > Create flag rule, clicked Save rule with both fields empty. Spinner appeared immediately, was still spinning after 10s, button reported [disabled] in the accessibility tree, and a second click changed nothing. "This field is required", "Please enter an amount." and "Please select a category." all rendered at the same time.

    Related issues

    No open duplicates found. Searched Expensify/App for "Save rule button loads infinitely" and "flag for review rule empty save" — this issue is the only match.


    💡 Suggested AI code review rule

    This same shape has already produced two occurrences and will recur on every new validation-gated page, so it may be worth a coding-standards rule so the AI reviewer catches the next one. Proposed for Expensify/App:

    • Rule: UI-4 — Opt out of the press spinner when the submit handler can return without navigating
    • Condition: Flag a FormAlertWithSubmitButton that passes neither shouldShowLoadingImmediatelyOnPress={false} nor an isLoading prop, when its onSubmit handler has an early return that only calls a setState (validation guard, permission guard). Add shouldShowLoadingImmediatelyOnPress={false}.
    • Why: The prop defaults to true, routing the press through usePressLoading, which clears isPressed only on external isLoading, a thrown handler, or screen re-focus. A handler that returns normally without navigating leaves the button spinning forever and unclickable. Caused this issue.
    • Search pattern: grep -rl "FormAlertWithSubmitButton" src/ | xargs grep -L "shouldShowLoadingImmediatelyOnPress\|isLoading=" then check each file's onSubmit handler for a setState-only early return.
    • Offending code (❌): FlagForReviewRulePageBase.tsx:169-215
    • Fix (✅): MerchantRulePageBase.tsx:641-648

    The full rule file, with the ❌/✅ code inline in App's coding-standards format, would go in .claude/skills/app-coding-standards/rules/ui-4-*.md. If it's worth adding, a maintainer can open it there as a draft PR.


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


    view run · view recording

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 24, 2026
  5. melvin-bot commented on Sep 24, 2026

    @melvin-bot

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

  6. melvin-bot commented on Sep 24, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  7. thesahindia commented on Sep 24, 2026

    @thesahindia
    Member

    @MelvinBot implement this.

  8. MelvinBot commented on Sep 24, 2026

    @MelvinBot
    Contributor

    🤖 Draft PR created: #102198

    Please mark it as "Ready for review" when it is ready for review.

    What changed — added shouldShowLoadingImmediatelyOnPress={false} to two rule pages, a one-line change each:

    This matches what the Merchant, Spend, Require fields, Spend card, and Require receipts rule pages already do.

    AI tests run:

    Check Result
    npm run lint-changed ✅ pass
    npm run typecheck ✅ pass
    npm run react-compiler-compliance-check ✅ pass
    npm run spell-changed ✅ pass
    npm test tests/unit/VendorMatchingMerchantRulesTest.ts ✅ pass (16/16)

    ⚠️ One gap: I could not confirm the fix in a browser. The automated web test session died partway through (blank page, no DOM nodes, no network activity) and there was no in-scope recovery path. The pre-fix behavior was reproduced in the browser during the investigation, so only the post-fix confirmation is missing. Please verify the flow manually before marking the PR ready.

    npm run prettier and npm run storybook --smoke-test from the standard matrix do not exist as scripts in this repo, so they were not run.

  9. 14 remaining items

  10. melvin-bot commented on Oct 6, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  11. melvin-bot commented on Oct 6, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  12. mallenexpensify commented on Oct 9, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @thesahindia due $175 via NewDot

    @thesahindia plz complete the Contributor+ checklist and tag me in a post once you have. Thx

  13. thesahindia commented on Oct 11, 2026

    @thesahindia
    Member

    Sorry for the delay on this one. Test steps are below:

    1. Go to Workspaces > Select any workspace
    2. Go to Rules > Flag for review > Create flag rule.
    3. Leave Category and Amount empty and click "Save rule".
    4. Verify the validation errors appear and the button does NOT spin, and stays clickable.
    5. Pick a Category and Amount, click "Save rule", verify it saves and navigates back.
    6. Repeat steps 2-3 on Workspace settings > Rules > Merchant type > a merchant type rule.
    7. Verify the validation errors appear and the button does NOT spin, and stays clickable.
  14. thesahindia commented on Oct 11, 2026

    @thesahindia
    Member
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.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorNot a priority

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions