Skip to content

[$175] Expensify Card - Next button replaced with loading button after enabled then disabled rule #104509

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.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

Action Performed:

  1. Open staging.new.expensify and login with applausetester@applause.expensifail.com
  2. Go to workspace which has expensify card enable
  3. Click on issue card
  4. Enter amount > next
  5. Enable Add spend rule
  6. Click on next
  7. Disable Add spend rule

Expected Result:

Next button should reappear after disable Add spend rule

Actual Result:

Next button replaced with loading button

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7291385_1792528396777.Recording__1249.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Svetlana Lazutkina
Bug ID: 7291385

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

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 20, 2026
  2. applause-bot commented on Oct 20, 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/3c4f987dc2da44fc4f2a31d85ee45b51f601b4682593569ac9892921521712aa

  3. MelvinBot commented on Oct 20, 2026

    @MelvinBot
    Contributor

    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.

    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 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.


    view run

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

    @melvin-bot

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

  6. 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
  7. melvin-bot commented on Oct 20, 2026

    @melvin-bot
  8. juni2003 commented on Oct 20, 2026

    @juni2003

    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 onSubmit handler combined with Expensify's usePressLoading hook.

    1. When the user clicks "Next", FormProvider.tsx triggers startWithLoading, which immediately sets the button's isPressed state to true to show the spinner.
    2. The execution passes to submit in src/pages/workspace/expensifyCard/issueNew/SetSpendRulesStep.tsx.
    3. Because the toggle is ON but no limit is set, lines 190-196 trigger an early return:
    if (hasSpendRule && !spendRule?.amount) {
        setRuleError(true);
        return;
    }
    1. 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.tsx
    const submit = () => {
        if (hasSpendRule && !spendRule?.amount) {
            setRuleError(true);
            return Promise.reject(new Error('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.

  9. melvin-bot commented on Oct 20, 2026

    @melvin-bot

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

  10. camesenin commented on Oct 20, 2026

    @camesenin
  11. melvin-bot commented on Oct 20, 2026

    @melvin-bot

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

  12. khizzcr7 commented on Oct 21, 2026

    @khizzcr7

    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?

    1. 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).
    2. isPressed is cleared in only three cases: the handler throws, the screen regains focus, or an external isLoading turns on.
    3. In src/pages/workspace/expensifyCard/issueNew/spendRules/SetSpendRulesStep.tsx, submit early-returns when no rule is configured:
      const formSpendRuleError = getSpendRuleErrorMessage();
      if (formSpendRuleError) {
          setSpendRuleErrorMessage(formSpendRuleError);
          return;
      }
      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).
    4. The spinner-on-press default came from PR Introduce the spinner on the FormAlertWithSubmitButton buttons #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 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.

  13. 24 remaining items

  14. melvin-bot commented on Nov 4, 2026

    @melvin-bot

    @Ollyws Huh... This is 4 days overdue. Who can take care of this?

  15. Ollyws commented on Nov 4, 2026

    @Ollyws
    Contributor

    @m-natarajan could we get a re-test on this? thanks!

  16. m-natarajan commented on Nov 5, 2026

    @m-natarajan

    Chrome / v9.5.32-3, Passed

    bandicam.2026-11-05.16-35-48-208.mp4
  17. Ollyws commented on Nov 5, 2026

    @Ollyws
    Contributor

    Ok we can close this then.

    🎀👀🎀 C+ reviewed

  18. melvin-bot commented on Nov 5, 2026

    @melvin-bot

    Triggered auto assignment to @danieldoglas, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

  19. jeffrey-graham commented on Nov 7, 2026

    @jeffrey-graham
  20. melvin-bot commented on Nov 7, 2026

    @melvin-bot
  21. melvin-bot commented on Nov 10, 2026

    @melvin-bot

    @danieldoglas Huh... This is 4 days overdue. Who can take care of this?

  22. melvin-bot commented on Nov 12, 2026

    @melvin-bot

    @danieldoglas Still overdue 6 days?! Let's take care of this!

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

Metadata

Metadata

Labels

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

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions