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-10-07] [$175] [Exploratory] Rules - Save rule button loads infinitely after saving empty values #100194
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.
Go to staging.new.expensify.com
Go to workspace settings > Rules > Flag for review.
Click Create flag rule.
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.
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.
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:
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.
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.
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.
Activity
applause-bot commentedon Sep 2, 2026
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
MelvinBot commentedon Sep 24, 2026
Proposal
Reproduced on web against current
main(e029fad): the spinner is still going 10s after the click, the button isdisabled, and further clicks do nothing — while the validation errors render correctly underneath.What is the root cause of that problem?
FormAlertWithSubmitButtonshows a spinner on every press unless the caller opts out, and the Flag for review page never opts out.The button's
shouldShowLoadingImmediatelyOnPressprop defaults totrue, so the press is routed throughstartWithLoading(onSubmit). That setsisPressed = trueinusePressLoading, which only ever clears it in three ways: an externalisLoadingflips true, the handler throws, or the screen regains focus.None of those happen here.
FlagForReviewRulePageBase.handleSubmitvalidates, callssetShouldShowError(true), and returns — no navigation, no throw — and the page passes noisLoadingto the button. SoisPressedstaystrueforever.The prop's own JSDoc says to set it to
false"whenonSubmitonly 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:
MerchantTypeRulePageBasehas a byte-identicalhandleSubmitand 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 theFormAlertWithSubmitButtonon both affected pages:FlagForReviewRulePageBase.tsx:205-215MerchantTypeRulePageBase.tsx:137-147This 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
isPressedafter the handler returns. InusePressLoading, resetisPressedin afinallyrather than only oncatch. 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
FormAlertWithSubmitButtonskipstartWithLoadingwhenisAlertVisibleis already true. Doesn't work: on the first pressshouldShowErroris stillfalse, 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.
usePressLoadingand the default-trueprop both arrived in Introduce the spinner on theFormAlertWithSubmitButtonbuttons (merged 2026-07-13), which hand-picked the pages that opt out.FlagForReviewRulePageBase.tsxandMerchantTypeRulePageBase.tsxboth landed onmainon 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/Appfor "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:UI-4— Opt out of the press spinner when the submit handler can return without navigatingFormAlertWithSubmitButtonthat passes neithershouldShowLoadingImmediatelyOnPress={false}nor anisLoadingprop, when itsonSubmithandler has an earlyreturnthat only calls asetState(validation guard, permission guard). AddshouldShowLoadingImmediatelyOnPress={false}.true, routing the press throughusePressLoading, which clearsisPressedonly on externalisLoading, a thrown handler, or screen re-focus. A handler that returns normally without navigating leaves the button spinning forever and unclickable. Caused this issue.grep -rl "FormAlertWithSubmitButton" src/ | xargs grep -L "shouldShowLoadingImmediatelyOnPress\|isLoading="then check each file'sonSubmithandler for asetState-only early return.FlagForReviewRulePageBase.tsx:169-215MerchantRulePageBase.tsx:641-648The 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
melvin-bot commentedon Sep 24, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @thesahindia (
External)melvin-bot commentedon Sep 24, 2026
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
thesahindia commentedon Sep 24, 2026
@MelvinBot implement this.
MelvinBot commentedon Sep 24, 2026
🤖 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:FlagForReviewRulePageBase.tsx:212— the reported bugMerchantTypeRulePageBase.tsx:144— the second instance flagged in the proposalThis matches what the Merchant, Spend, Require fields, Spend card, and Require receipts rule pages already do.
AI tests run:
npm run lint-changednpm run typechecknpm run react-compiler-compliance-checknpm run spell-changednpm test tests/unit/VendorMatchingMerchantRulesTest.tsnpm run prettierandnpm run storybook --smoke-testfrom the standard matrix do not exist as scripts in this repo, so they were not run.14 remaining items
melvin-bot commentedon Oct 6, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Oct 6, 2026
Payment Summary
Resolving PRs:
Stop the rule Save button spinning forever when validation fails #102198
Reviewer: @thesahindia owed $175 via NewDot
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Oct 9, 2026
Payment Summary
Contributor+: @thesahindia due $175 via NewDot
@thesahindia plz complete the Contributor+ checklist and tag me in a post once you have. Thx
thesahindia commentedon Oct 11, 2026
Sorry for the delay on this one. Test steps are below:
thesahindia commentedon Oct 11, 2026
@mallenexpensify please check #100194 (comment)