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
[$175] Expensify Card - Next button replaced with loading button after enabled then disabled rule #104509
Version Number: 9.5.15-1 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack:#103365 Email or phone of affected tester (no customers):applausetester@applause.expensifail.com Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: Windows 11 / Chrome App Component: Other
Please re-state the problem that we are trying to solve in this issue.
On the Issue card "Set card rules" step, if you turn on Add spend rule, click Next without setting a rule, and then turn the toggle off, the Next button stays a spinner. You can't press it, so you're stuck.
What is the root cause of that problem?
Clicking Next turns on the form's "spinner on press" state. The step's submit handler then stops early because no spend rule is set, so it never moves on. Nothing clears the spinner after that early stop.
isPressed is cleared in only three cases: the handler throws, the screen regains focus, or an external isLoading turns on. The early return in SetSpendRulesStep's submit triggers none of them (SetSpendRulesStep.tsx:190-196).
What changes do you think we should make in order to solve the problem?
Pass shouldShowLoadingImmediatelyOnPress={false} to the FormProvider in SetSpendRulesStep (SetSpendRulesStep.tsx:273-281). Next here only writes local Onyx data, so the user never waits long enough to need a spinner. Other forms already do this, for example RulePageBase.tsx and ReportAddApproverPage.tsx.
What alternative solutions did you explore? (Optional)
Fix it once in the shared hook: let onSubmit return false for "did not submit," and have startWithLoading clear isPressed when that happens. This would protect any other form whose submit handler stops early. It touches shared form components, so it's a bigger change than this bug needs.
Investigation notes
Confidence: high on the mechanism, from tracing the code. I didn't reproduce it in a running app.
Why it sometimes recovers: opening a rule sub-page (for example, "Max amount") and coming back refocuses the screen. The useFocusEffect in usePressLoading then clears the spinner.
validate in this step checks only the expiration dates. It passes with the toggle on and no rule set, so the press reaches submit.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/104509) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
changed the title [-]Expensify Card - Next button replaced with loading button after enabled then disabled rule[/-][+][$175] Expensify Card - Next button replaced with loading button after enabled then disabled rule[/+]on Oct 20, 2026
Please re-state the problem that we are trying to solve in this issue.
On the "Set card rules" step of issuing an Expensify Card, clicking "Next" with the "Add spend rule" toggle ON (but no rule actually configured) leaves the "Next" button permanently stuck in a loading state, even if the user subsequently turns the toggle OFF.
What is the root cause of that problem?
The root cause is an unhandled early return inside the form's onSubmit handler combined with Expensify's usePressLoading hook.
When the user clicks "Next", FormProvider.tsx triggers startWithLoading, which immediately sets the button's isPressed state to true to show the spinner.
The execution passes to submit in src/pages/workspace/expensifyCard/issueNew/SetSpendRulesStep.tsx.
Because the toggle is ON but no limit is set, lines 190-196 trigger an early return:
Because the onSubmit function returns undefined instead of a rejected Promise or throwing an error, usePressLoading.ts assumes the submission was "successful." Since the screen did not unmount or lose focus (which are the only other ways the spinner clears), the isPressed state is permanently orphaned as true.
What changes do you think we should make in order to solve the problem?
We should not disable the loading spinner (as MelvinBot suggested), as that degrades the standard form UX. Instead, the onSubmit early return must inform the FormProvider that the submission was aborted so the usePressLoading hook naturally clears the spinner.
In src/pages/workspace/expensifyCard/issueNew/SetSpendRulesStep.tsx, update the submit function to return a rejected Promise when the spend rule guard is hit:
// src/pages/workspace/expensifyCard/issueNew/SetSpendRulesStep.tsxconstsubmit=()=>{if(hasSpendRule&&!spendRule?.amount){setRuleError(true);returnPromise.reject(newError('Spend rule amount is required'));// FormProvider catches this and clears the spinner}if(hasSpendRule){IssueNewCardFlow.setIssueNewCardData({// ...
Because FormProvider wraps the onSubmit call in a try/catch and .catch() chain, rejecting the promise natively resolves the stuck spinner while maintaining the required UX loading state for successful submissions.
What alternative solutions did you explore? (Optional)
MelvinBot suggested passing shouldShowLoadingImmediatelyOnPress={false} to the FormProvider. This was rejected because it removes visual feedback from the button entirely. While IssueNewCardFlow Onyx writes are fast, standardizing on no-spinner forms creates UX inconsistency across the app. Rejecting the Promise fixes the root cause at the state-machine level without compromising the UI feedback loop.
Please re-state the problem that we are trying to solve in this issue.
On the Issue card "Set card rules" step, turning on "Add spend rule", clicking Next without configuring a rule, then turning the toggle off leaves the Next button permanently stuck in a loading spinner state, blocking progression.
What is the root cause of that problem?
FormProvider shows a spinner on press by default (shouldShowLoadingImmediatelyOnPress = true, src/components/Form/FormProvider.tsx:156). startWithLoading sets isPressed = true before running onSubmit (FormProvider.tsx:355).
isPressed is cleared in only three cases: the handler throws, the screen regains focus, or an external isLoading turns on.
In src/pages/workspace/expensifyCard/issueNew/spendRules/SetSpendRulesStep.tsx, submit early-returns when no rule is configured:
The early return triggers none of the three reset paths, so the spinner never clears. Turning the toggle off only clears the error text (SetSpendRulesStep.tsx:111-117); later presses are ignored (FormProvider.tsx:311).
What changes do you think we should make in order to solve the problem?
Pass shouldShowLoadingImmediatelyOnPress={false} to the FormProvider in SetSpendRulesStep (lines 273-281). Next here only writes local Onyx data, so the user never waits long enough to need a spinner; precedent exists in RulePageBase.tsx and ReportAddApproverPage.tsx. This removes the stuck-spinner state for every early-return path rather than patching each one. I will re-verify the full toggle on -> Next -> error -> toggle off -> Next flow after the change.
Tests: submit with the toggle on and no rule set, assert the button is not left in a loading state after the error appears; turn the toggle off, press Next, assert navigation proceeds.
Activity
applause-bot commentedon Oct 20, 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/3c4f987dc2da44fc4f2a31d85ee45b51f601b4682593569ac9892921521712aa
MelvinBot commentedon Oct 20, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On the Issue card "Set card rules" step, if you turn on Add spend rule, click Next without setting a rule, and then turn the toggle off, the Next button stays a spinner. You can't press it, so you're stuck.
What is the root cause of that problem?
Clicking Next turns on the form's "spinner on press" state. The step's submit handler then stops early because no spend rule is set, so it never moves on. Nothing clears the spinner after that early stop.
FormProvidershows a spinner on press by default (FormProvider.tsx:156). It callsstartWithLoading, which setsisPressed = truebefore it runsonSubmit(FormProvider.tsx:355, usePressLoading.ts:35-46).isPressedis cleared in only three cases: the handler throws, the screen regains focus, or an externalisLoadingturns on. The earlyreturninSetSpendRulesStep'ssubmittriggers none of them (SetSpendRulesStep.tsx:190-196).The spinner-on-press default came from Introduce the spinner on the `FormAlertWithSubmitButton` buttons. The early return in this step is older and was harmless before that change. It is not related to Return to the spend rule form after upgrading from a workspace spend rule page, the PR under QA when this was found.
What changes do you think we should make in order to solve the problem?
Pass
shouldShowLoadingImmediatelyOnPress={false}to theFormProviderinSetSpendRulesStep(SetSpendRulesStep.tsx:273-281). Next here only writes local Onyx data, so the user never waits long enough to need a spinner. Other forms already do this, for exampleRulePageBase.tsxandReportAddApproverPage.tsx.What alternative solutions did you explore? (Optional)
Fix it once in the shared hook: let
onSubmitreturnfalsefor "did not submit," and havestartWithLoadingclearisPressedwhen that happens. This would protect any other form whose submit handler stops early. It touches shared form components, so it's a bigger change than this bug needs.Investigation notes
useFocusEffectinusePressLoadingthen clears the spinner.validatein this step checks only the expiration dates. It passes with the toggle on and no rule set, so the press reachessubmit.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/104509)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run
melvin-bot commentedon Oct 20, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @eh2077 (
External)[-]Expensify Card - Next button replaced with loading button after enabled then disabled rule[/-][+][$175] Expensify Card - Next button replaced with loading button after enabled then disabled rule[/+]melvin-bot commentedon Oct 20, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022112649059231981593
juni2003 commentedon Oct 20, 2026
Contributor details
Your Expensify account email: juni.xatti@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~01867ae3203c9b7815?mp_source=share
Proposal
Please re-state the problem that we are trying to solve in this issue.
On the "Set card rules" step of issuing an Expensify Card, clicking "Next" with the "Add spend rule" toggle ON (but no rule actually configured) leaves the "Next" button permanently stuck in a loading state, even if the user subsequently turns the toggle OFF.
What is the root cause of that problem?
The root cause is an unhandled early return inside the form's
onSubmithandler combined with Expensify'susePressLoadinghook.FormProvider.tsxtriggersstartWithLoading, which immediately sets the button'sisPressedstate totrueto show the spinner.submitinsrc/pages/workspace/expensifyCard/issueNew/SetSpendRulesStep.tsx.onSubmitfunction returnsundefinedinstead of a rejected Promise or throwing an error,usePressLoading.tsassumes the submission was "successful." Since the screen did not unmount or lose focus (which are the only other ways the spinner clears), theisPressedstate is permanently orphaned astrue.What changes do you think we should make in order to solve the problem?
We should not disable the loading spinner (as MelvinBot suggested), as that degrades the standard form UX. Instead, the
onSubmitearly return must inform theFormProviderthat the submission was aborted so theusePressLoadinghook naturally clears the spinner.In
src/pages/workspace/expensifyCard/issueNew/SetSpendRulesStep.tsx, update thesubmitfunction to return a rejected Promise when the spend rule guard is hit:Because
FormProviderwraps theonSubmitcall in atry/catchand.catch()chain, rejecting the promise natively resolves the stuck spinner while maintaining the required UX loading state for successful submissions.What alternative solutions did you explore? (Optional)
MelvinBot suggested passing
shouldShowLoadingImmediatelyOnPress={false}to theFormProvider. This was rejected because it removes visual feedback from the button entirely. WhileIssueNewCardFlowOnyx writes are fast, standardizing on no-spinner forms creates UX inconsistency across the app. Rejecting the Promise fixes the root cause at the state-machine level without compromising the UI feedback loop.melvin-bot commentedon Oct 20, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
camesenin commentedon Oct 20, 2026
melvin-bot commentedon Oct 20, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
khizzcr7 commentedon Oct 21, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On the Issue card "Set card rules" step, turning on "Add spend rule", clicking Next without configuring a rule, then turning the toggle off leaves the Next button permanently stuck in a loading spinner state, blocking progression.
What is the root cause of that problem?
FormProvidershows a spinner on press by default (shouldShowLoadingImmediatelyOnPress = true,src/components/Form/FormProvider.tsx:156).startWithLoadingsetsisPressed = truebefore runningonSubmit(FormProvider.tsx:355).isPressedis cleared in only three cases: the handler throws, the screen regains focus, or an externalisLoadingturns on.src/pages/workspace/expensifyCard/issueNew/spendRules/SetSpendRulesStep.tsx,submitearly-returns when no rule is configured:returntriggers none of the three reset paths, so the spinner never clears. Turning the toggle off only clears the error text (SetSpendRulesStep.tsx:111-117); later presses are ignored (FormProvider.tsx:311).FormAlertWithSubmitButtonbuttons #92498; the early return predates it and was harmless before. The PR under QA (Return to the spend rule form after upgrading from a workspace spend rule page #103365) is unrelated.What changes do you think we should make in order to solve the problem?
Pass
shouldShowLoadingImmediatelyOnPress={false}to theFormProviderinSetSpendRulesStep(lines 273-281). Next here only writes local Onyx data, so the user never waits long enough to need a spinner; precedent exists inRulePageBase.tsxandReportAddApproverPage.tsx. This removes the stuck-spinner state for every early-return path rather than patching each one. I will re-verify the full toggle on -> Next -> error -> toggle off -> Next flow after the change.Tests: submit with the toggle on and no rule set, assert the button is not left in a loading state after the error appears; turn the toggle off, press Next, assert navigation proceeds.
24 remaining items
melvin-bot commentedon Nov 4, 2026
@Ollyws Huh... This is 4 days overdue. Who can take care of this?
Ollyws commentedon Nov 4, 2026
@m-natarajan could we get a re-test on this? thanks!
m-natarajan commentedon Nov 5, 2026
Chrome / v9.5.32-3, Passed
bandicam.2026-11-05.16-35-48-208.mp4
Ollyws commentedon Nov 5, 2026
Ok we can close this then.
🎀👀🎀 C+ reviewed
melvin-bot commentedon Nov 5, 2026
Triggered auto assignment to @danieldoglas, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
jeffrey-graham commentedon Nov 7, 2026
melvin-bot commentedon Nov 7, 2026
melvin-bot commentedon Nov 10, 2026
@danieldoglas Huh... This is 4 days overdue. Who can take care of this?
melvin-bot commentedon Nov 12, 2026
@danieldoglas Still overdue 6 days?! Let's take care of this!