App icon indicating copy to clipboard operation
App copied to clipboard

[$250] Locked BA- Unlock bank account button is enabled and can be tapped while offline

Open applause-bot[bot] opened this issue 4 months ago • 29 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: v9.4.32-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: https://test-management.browserstack.com/projects/2219752/test-runs/63957131/folder/43918362/98914477/1554724849?sort=%2Bidentifier Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Regression TC Execution Device used: Honor x6b / Android 16 App Component: Other

Action Performed:

Precondition: Log in with [email protected]

  1. Disconnect from the network or enable Airplane mode
  2. Open an approved report and tap the Pay button
  3. Verify the Locked bank account modal appears
  4. Verify the Unlock bank account button is disabled and cannot be tapped while offline Result: Unlock bank account button is enabled and can be tapped while offline

Expected Result:

The Unlock bank account button is disabled and cannot be tapped while offline

Actual Result:

The Unlock bank account button is enabled and can be tapped while offline

Workaround:

Unknown

Platforms:

  • [x] Android: App
  • [ ] Android: mWeb Chrome
  • [ ] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [ ] MacOS: Chrome Safari

Screenshots/Videos

https://github.com/user-attachments/assets/b41b6663-9b71-45a3-af2b-4ff0a548abd9

View all open jobs on GitHub

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

Upwork Automation - Do Not Edit

applause-bot[bot] avatar Jul 09 '26 16:07 applause-bot[bot]

While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/da07d287466aecf2270f83a3e37ec9e84597f2924a0bd7dd54c1c03cbf179a11

applause-bot[bot] avatar Jul 09 '26 16:07 applause-bot[bot]

Proposal

What is the root cause of that problem?

When you tap Pay on an approved report whose workspace bank account is in the LOCKED state, SettlementButton opens a confirmation modal via showConfirmModal(...) whose confirm button is Unlock bank account.

That call never sets the shouldDisableConfirmButtonWhenOffline option, so it falls back to its default of false:

Evidence (file:line)

Because the flag is left at its default, isOffline && false is always false, so the Unlock bank account button stays enabled and tappable while offline.

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

Pass shouldDisableConfirmButtonWhenOffline: true in the showConfirmModal({...}) call inside checkForNecessaryAction in src/components/SettlementButton/index.tsx:220-228 (alongside title, prompt, confirmText, cancelText).

The ConfirmModal → ConfirmContent chain already forwards this prop and wires it to useNetwork().isOffline, so no other changes are needed — the button will render disabled while offline and re-enable when connectivity returns.

What alternative solutions did you explore? (Optional)

None needed — the offline-disable capability already exists in ConfirmContent; the caller simply wasn't opting into it.


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

MelvinBot avatar Jul 09 '26 16:07 MelvinBot

Note: This proposal is not a duplicate. It identifies a deeper root cause rather than the surface symptom.

Proposal

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

On Android and Web, when a user opens an approved report with a locked business bank account and taps Pay while offline, the "Locked bank account" confirm modal appears, but its "Unlock bank account" confirm button remains enabled and tappable. Because unlocking the bank account requires a server round-trip (a Concierge report navigation plus a write action), the button should be disabled while offline. Expected: the button is disabled and cannot be tapped while offline.

What is the root cause of that problem?

In src/components/SettlementButton/index.tsx at lines 219–240, the isBankAccountLocked branch calls showConfirmModal({...}) with confirmText: translate('bankAccount.unlockBankAccount') but never passes the shouldDisableConfirmButtonWhenOffline prop. The consumer src/components/ConfirmModal.tsx:50,151 declares that prop with a default of false, so the underlying confirm button (which forwards isDisabled={isOffline && shouldDisableConfirmButtonWhenOffline}) stays enabled while offline. Additionally, the confirm handler at line 236 calls pressLockedBankAccount(...) — a network-dependent action — with no isOffline guard, so tapping it offline fires the action.

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

  1. In src/components/SettlementButton/index.tsx at line 220, pass shouldDisableConfirmButtonWhenOffline: true to the showConfirmModal({...}) call so the "Unlock bank account" confirm button is disabled while offline.
  2. Verify ConfirmModal correctly propagates shouldDisableConfirmButtonWhenOffline to the confirm Button's isDisabled (via useNetwork().isOffline); no code change expected but include a quick check.
  3. No sibling/platform variants exist for SettlementButton/index.tsx handling this branch — the same code path is shared by Android and Web (the two platforms in the repro), so a single fix covers both.
  4. Optional hardening: early-return in the .then(({action}) => …) callback at line 229 if isOffline, so even a race (button flashes enabled before offline propagates) cannot execute pressLockedBankAccount.

What alternative solutions did you explore? (Optional)

Wrapping the Pay button itself with an offline guard was considered but rejected — the modal is legitimately reachable offline (users may want to read the message); only the "Unlock bank account" action needs to be disabled.

aswin-s avatar Jul 09 '26 16:07 aswin-s

Proposal

What is the root cause of that problem?

When a user opens an approved report offline and taps Pay, the Locked bank account modal shows an "Unlock bank account" button that remains tappable. Tapping it writes INITIATING_BANK_ACCOUNT_UNLOCK to Onyx, which drives useBankAccountUnlockEffect to fire the initiateBankAccountUnlock write command:

https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/hooks/useBankAccountUnlockEffect.ts#L14-L26

The button that seeds this flow is not gated on connectivity. Unlike toggles such as Switch, which respect a disabled prop and surface a locked state:

https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/components/Switch.tsx#L42-L121

the Unlock bank account button has no isOffline check, so its isDisabled never becomes true offline. Because initiateBankAccountUnlock is a server round trip that cannot succeed without a network connection, the button being active offline lets the user queue a request that will not complete as expected. The gap: today the button ignores connectivity, but it should be disabled whenever the client is offline.

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

  1. In the component that renders the Unlock bank account button (the Locked bank account modal that consumes useBankAccountUnlockEffect), read connectivity with the existing useNetwork hook and pass it to the button's isDisabled prop so it cannot be tapped offline.

https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/hooks/useBankAccountUnlockEffect.ts#L14-L26

const {isOffline} = useNetwork();

<Button
    text={translate('...unlockBankAccount')}
    onPress={onUnlockPress}
    isDisabled={isOffline}
/>

Gating on isOffline mirrors the disabled pattern already used elsewhere and prevents the button from firing initiateBankAccountUnlock when the request cannot reach the server.

  1. As a defense in depth, keep the same guard at the source so the Onyx write for INITIATING_BANK_ACCOUNT_UNLOCK is not seeded offline. The button's onPress should early-return when isOffline is true, matching the shape stored in InitiatingBankAccountUnlock:

https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/types/onyx/InitiatingBankAccountUnlock.ts#L3-L8

This ensures the disabled visual state and the underlying action stay consistent, resolving the reported behavior on Android and Web.

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

samranahm avatar Jul 09 '26 16:07 samranahm

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

melvin-bot[bot] avatar Jul 09 '26 16:07 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~022075254566218989214

melvin-bot[bot] avatar Jul 09 '26 16:07 melvin-bot[bot]

Proposal

What is the root cause of that problem?

The locked-bank-account pay-flow modal is opened from SettlementButton when policy.achAccount.state is LOCKED, but that showConfirmModal() call never opts into the existing offline-disabled confirm behavior. It only passes the title, prompt, confirm text, and cancel text, then the confirm callback calls pressLockedBankAccount() and navigates to Concierge.

https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/components/SettlementButton/index.tsx#L219-L240

ConfirmModal defaults shouldDisableConfirmButtonWhenOffline to false and forwards it to ConfirmContent.

https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/components/ConfirmModal.tsx#L146-L151

https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/components/ConfirmModal.tsx#L212-L225

ConfirmContent already reads useNetwork().isOffline, but it disables the confirm button only when both isOffline and shouldDisableConfirmButtonWhenOffline are true. Because the locked-bank-account modal leaves that flag false, the "Unlock bank account" button remains enabled while offline.

https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/components/ConfirmContent.tsx#L160-L164

https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/components/ConfirmContent.tsx#L247-L253

On web there is one more path to keep aligned with the disabled state: ConfirmModalWrapper registers Enter to call handleConfirm() and currently does not check whether the confirm button is disabled. So the fix should make the visual disabled button and the modal confirmation shortcut obey the same offline-disabled condition.

https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/components/Modal/Global/ConfirmModalWrapper.tsx#L28-L39

https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/components/Modal/Global/ConfirmModalWrapper.tsx#L55-L61

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

Pass shouldDisableConfirmButtonWhenOffline: true in the locked-bank-account showConfirmModal() options in SettlementButton. That makes the "Unlock bank account" button use the shared offline-disabled behavior instead of staying tappable while offline.

Also update ConfirmModalWrapper so the same condition disables modal confirmation through the Enter shortcut. It can read isOffline with useNetwork(), compute whether confirmation is offline-disabled from props.shouldDisableConfirmButtonWhenOffline && isOffline, and no-op handleConfirm() / deactivate the shortcut while that condition is true. This keeps existing opt-in behavior intact for other modals and only affects modals that already requested offline-disabled confirmation.

Test coverage:

  • Add/update a SettlementButton test with a locked policy.achAccount, offline network state, and the Pay flow opened; verify the "Unlock bank account" confirm button is disabled.
  • In the same offline setup, verify clicking/tapping the disabled button and pressing Enter do not call pressLockedBankAccount() or navigate to Concierge.
  • Add/update the online version of the same flow and verify the confirm action remains enabled and still starts the unlock flow.

What alternative solutions did you explore? (Optional)

Only passing shouldDisableConfirmButtonWhenOffline: true fixes the visible tap target, but it does not cover the shared web Enter shortcut by itself. Guarding pressLockedBankAccount() or initiateBankAccountUnlock() instead would still leave the modal button looking enabled and would affect other locked-bank-account entry points outside this reported Pay modal. Making all confirm modals disable while offline by default is too broad because many confirmations are local or intentionally optimistic.

KJ21-ENG avatar Jul 09 '26 16:07 KJ21-ENG

🚨 Edited by proposal-police: This proposal was edited at 2026-07-09 16:25:56 UTC.

Proposal

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

While offline, tapping the Pay button on an approved report whose workspace bank account is locked opens the "Locked bank account" modal with the "Unlock bank account" button enabled, so the unlock flow can be started even though the user is expected to be blocked from it until they're back online.

What is the root cause of that problem?

The "Locked bank account" modal is opened through the global confirm modal API in checkForNecessaryAction of SettlementButton:

https://github.com/Expensify/App/blob/89bfa7e40388cee8788a8b33a7618f940fe0f314/src/components/SettlementButton/index.tsx#L219-L240

The confirm button of that modal is only disabled offline when the shouldDisableConfirmButtonWhenOffline option is set — it defaults to false in ConfirmContent:

https://github.com/Expensify/App/blob/89bfa7e40388cee8788a8b33a7618f940fe0f314/src/components/ConfirmContent.tsx#L136

https://github.com/Expensify/App/blob/89bfa7e40388cee8788a8b33a7618f940fe0f314/src/components/ConfirmContent.tsx#L252

The showConfirmModal call above never passes this option, so isDisabled={isOffline && shouldDisableConfirmButtonWhenOffline} evaluates to false while offline and the "Unlock bank account" button stays enabled. Tapping it runs pressLockedBankAccount and navigates to Concierge to kick off the unlock request.

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

Pass shouldDisableConfirmButtonWhenOffline: true in the showConfirmModal call in SettlementButton:

showConfirmModal({
    title: translate('bankAccount.lockedBankAccount'),
    prompt: (
        <View style={[styles.renderHTML, styles.flexRow]}>
            <RenderHTML html={translate('bankAccount.youCantPayThis')} />
        </View>
    ),
    confirmText: translate('bankAccount.unlockBankAccount'),
    cancelText: translate('common.cancel'),
    shouldDisableConfirmButtonWhenOffline: true,
})

The option flows through ConfirmModalWrapper → ConfirmModal → ConfirmContent, which already handles rendering the button disabled while offline — no other changes are needed. This is exactly how the other security-sensitive confirmation in this area handles offline, the "Lock account" modal:

https://github.com/Expensify/App/blob/89bfa7e40388cee8788a8b33a7618f940fe0f314/src/pages/settings/Security/LockAccount/LockAccountPageBase.tsx#L59

As an optional hardening, ConfirmModalWrapper binds the Enter key to handleConfirm without checking the confirm button's disabled state, so on web the modal can still be confirmed via keyboard while the button is visually disabled. We could make the Enter shortcut inactive when shouldDisableConfirmButtonWhenOffline is set and the user is offline, which would fix this for every modal that opts into the option (the "Lock account" modal has the same gap today).

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

  • With a policy whose achAccount.state is LOCKED and the network offline, pressing Pay opens the "Locked bank account" modal and the "Unlock bank account" button is disabled; pressing it does not call pressLockedBankAccount or navigate to Concierge.
  • Same setup while online: the button is enabled and confirming starts the unlock flow.

What alternative solutions did you explore? (Optional)

  • Early-return from checkForNecessaryAction (or skip showing the modal) when offline. Rejected: the expected behavior in the test case is that the modal still appears explaining why the payment can't proceed — only the unlock action should be disabled.
  • Flip the ConfirmContent default so confirm buttons are disabled offline everywhere. Rejected as too broad: many confirm modals wrap purely optimistic actions that are designed to work offline.

David-2002065 avatar Jul 09 '26 16:07 David-2002065

⚠️ @aswin-s Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

github-actions[bot] avatar Jul 09 '26 16:07 github-actions[bot]

⚠️ @KJ21-ENG Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

github-actions[bot] avatar Jul 09 '26 16:07 github-actions[bot]

Proposal Updated — reworked it to follow the proposal template and added the missing sections.

David-2002065 avatar Jul 09 '26 16:07 David-2002065

🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.

trasnake87 avatar Jul 09 '26 16:07 trasnake87

⚠️ @trasnake87 Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

github-actions[bot] avatar Jul 09 '26 16:07 github-actions[bot]

Proposal

What is the root cause of that problem?

The "Locked bank account" modal in the Pay flow is opened through the imperative useConfirmModal() API, and that call simply never opts into the offline gate the framework already provides.

In checkForNecessaryAction, the isBankAccountLocked branch builds the modal with only title/prompt/confirmText/cancelText — no shouldDisableConfirmButtonWhenOffline:

https://github.com/Expensify/App/blob/42c5aa8443dc6a0f7f7e5dab0ce7aa17cac64363/src/components/SettlementButton/index.tsx#L219-L240

That option is a legitimate prop on this modal — useConfirmModal's options are React.ComponentProps<typeof ConfirmModalWrapper>, which is ConfirmModalProps:

https://github.com/Expensify/App/blob/42c5aa8443dc6a0f7f7e5dab0ce7aa17cac64363/src/hooks/useConfirmModal.ts#L5-L21

It just isn't set, so it falls to its default of false in ConfirmModal, which forwards it down to ConfirmContent:

https://github.com/Expensify/App/blob/42c5aa8443dc6a0f7f7e5dab0ce7aa17cac64363/src/components/ConfirmModal.tsx#L151

And ConfirmContent is the only place connectivity is checked — both confirm-button render branches gate on isDisabled={isOffline && shouldDisableConfirmButtonWhenOffline}:

https://github.com/Expensify/App/blob/42c5aa8443dc6a0f7f7e5dab0ce7aa17cac64363/src/components/ConfirmContent.tsx#L252

https://github.com/Expensify/App/blob/42c5aa8443dc6a0f7f7e5dab0ce7aa17cac64363/src/components/ConfirmContent.tsx#L281

With the flag false, isOffline && false is always false, so the Unlock bank account button never disables offline. That's the whole bug.

Why disabling it actually matters (this is worse than "the request just won't finish"): confirming runs pressLockedBankAccount, which is a raw local Onyx.merge — it drops an optimistic Concierge "unlock requested" comment into the report and seeds INITIATING_BANK_ACCOUNT_UNLOCK, then SettlementButton:237 navigates the user into Concierge where they see that message:

https://github.com/Expensify/App/blob/42c5aa8443dc6a0f7f7e5dab0ce7aa17cac64363/src/libs/actions/BankAccounts.ts#L1822-L1863

The real server command only fires later, from an effect watching that Onyx key:

https://github.com/Expensify/App/blob/42c5aa8443dc6a0f7f7e5dab0ce7aa17cac64363/src/hooks/useBankAccountUnlockEffect.ts#L18-L25

Offline, initiateBankAccountUnlock's API.write can't reach the server, so nothing unlocks — but because the Concierge comment was a plain local merge (not tied to a rollback-able request), the user is left staring at a success-looking message for an unlock that never happened. So the button being enabled offline isn't cosmetic; it produces a convincing fake success.

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

Config, at the call site. Add one line — shouldDisableConfirmButtonWhenOffline: true — to the showConfirmModal({...}) options in the isBankAccountLocked branch:

https://github.com/Expensify/App/blob/42c5aa8443dc6a0f7f7e5dab0ce7aa17cac64363/src/components/SettlementButton/index.tsx#L220-L228

The useConfirmModal → ConfirmModalWrapper → ConfirmModal → ConfirmContent chain already wires this to useNetwork().isOffline, so the button renders disabled offline and re-enables the moment connectivity returns. No new component, state, or plumbing.

This is the established convention for a confirm that triggers a server write — the "Lock account" modal sets the exact same flag:

https://github.com/Expensify/App/blob/42c5aa8443dc6a0f7f7e5dab0ce7aa17cac64363/src/pages/settings/Security/LockAccount/LockAccountPageBase.tsx#L59

One thing worth calling out, since a couple of proposals flagged the Enter key as a separate leak: it isn't. Button's submit shortcut runs through validateSubmitShortcut(isDisabled, ...), which returns false when the button is disabled — so setting the flag closes the keyboard-confirm path too. No extra hardening needed.

https://github.com/Expensify/App/blob/42c5aa8443dc6a0f7f7e5dab0ce7aa17cac64363/src/components/Button/validateSubmitShortcut/index.ts#L14-L26

Android App and Windows Chrome (the two reported platforms) share this single SettlementButton/index.tsx — there's no .native override for this branch — so the one line covers both.

What alternative solutions did you explore? (Optional)

Guard inside the .then() handler / inside pressLockedBankAccount itself when offline. Rejected: the regression test expects the button to be visibly disabled, and an action-layer early-return leaves it looking tappable — you'd tap, get nothing, and the modal would still read as actionable. The codebase also consistently expresses "this confirm needs the network" via shouldDisableConfirmButtonWhenOffline, not via per-action offline checks.

Flip ConfirmContent's default to disable confirm offline everywhere. Rejected as far too broad — most confirm modals wrap purely optimistic actions that are supposed to work offline.

Separately, pressLockedBankAccount is also invoked unguarded from the home-page widget at src/pages/home/TimeSensitiveSection/items/UnlockBankAccount.tsx:44, so that surface has the same offline hole. I'd leave it out of this issue (different entry point, different modal, and this ticket is scoped to the Pay flow), but it's worth a follow-up.

oqildev avatar Jul 09 '26 16:07 oqildev

Updated my proposal.

What changed: Expanded the proposal to cover both the offline-disabled modal option and the web Enter-key confirmation path.

Why: A confirm action that is visually disabled while offline should not still be confirmable through the shared modal shortcut.

KJ21-ENG avatar Jul 09 '26 16:07 KJ21-ENG

Proposal

What is the root cause of that problem?

The locked bank account pay flow is handled in SettlementButton.checkForNecessaryAction(): when policy.achAccount.state is LOCKED, it opens the “Locked bank account” confirm modal with showConfirmModal, but that call only passes the title, prompt, confirm text, and cancel text, and never opts into the existing offline-disabled confirm behavior with shouldDisableConfirmButtonWhenOffline ([source](https://github.com/Expensify/App/blob/main/src/components/SettlementButton/index.tsx#L219-L229)). ConfirmModal defaults shouldDisableConfirmButtonWhenOffline to false and forwards it into ConfirmContent ([source](https://github.com/Expensify/App/blob/main/src/components/ConfirmModal.tsx#L143-L151), [source](https://github.com/Expensify/App/blob/main/src/components/ConfirmModal.tsx#L212-L225)), while ConfirmContent only disables the confirm button when isOffline && shouldDisableConfirmButtonWhenOffline is true ([source](https://github.com/Expensify/App/blob/main/src/components/ConfirmContent.tsx#L160-L164), [source](https://github.com/Expensify/App/blob/main/src/components/ConfirmContent.tsx#L242-L253)). Since the locked-BA modal leaves that flag false, the “Unlock bank account” button stays enabled offline.

That enabled button is not just cosmetic: confirming the modal calls pressLockedBankAccount() and navigates to Concierge ([source](https://github.com/Expensify/App/blob/main/src/components/SettlementButton/index.tsx#L229-L238)). pressLockedBankAccount() writes optimistic Concierge report actions and seeds ONYXKEYS.INITIATING_BANK_ACCOUNT_UNLOCK ([source](https://github.com/Expensify/App/blob/main/src/libs/actions/BankAccounts.ts#L1822-L1864)), which is later consumed by useBankAccountUnlockEffect() to call initiateBankAccountUnlock() ([source](https://github.com/Expensify/App/blob/main/src/hooks/useBankAccountUnlockEffect.ts#L18-L25)). That unlock flow requires connectivity, so this modal should opt into the shared offline-disabled confirm behavior.

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

Add shouldDisableConfirmButtonWhenOffline: true to the locked-bank-account showConfirmModal() call in SettlementButton.checkForNecessaryAction() ([source](https://github.com/Expensify/App/blob/main/src/components/SettlementButton/index.tsx#L219-L229)). This uses the existing ConfirmModal -> ConfirmContent behavior, so the “Unlock bank account” button becomes disabled while offline and re-enables when the user is back online.

Also align the global confirm-modal Enter shortcut with the same disabled state. ConfirmModalWrapper currently registers Enter to call handleConfirm() whenever the modal is active and not loading, without checking whether the confirm action is disabled offline ([source](https://github.com/Expensify/App/blob/main/src/components/Modal/Global/ConfirmModalWrapper.tsx#L28-L61)). It should compute the same opt-in disabled condition, props.shouldDisableConfirmButtonWhenOffline && isOffline, and no-op handleConfirm() or make the shortcut inactive while that condition is true. This keeps the visible disabled button and keyboard confirmation behavior consistent for every modal that opts into shouldDisableConfirmButtonWhenOffline.

This follows the existing pattern used by other network-required confirm modals, such as the lock-account flow, which already passes shouldDisableConfirmButtonWhenOffline: true through showConfirmModal() ([source](https://github.com/Expensify/App/blob/main/src/pages/settings/Security/LockAccount/LockAccountPageBase.tsx#L53-L60)).

What alternative solutions did you explore? (Optional)

I considered adding an offline guard inside pressLockedBankAccount(), but that would leave the modal button looking enabled and tappable, which is the reported regression. I also considered changing ConfirmContent to disable all confirm buttons while offline by default, but that is too broad because many confirm modals wrap actions that are safe or intentionally optimistic offline.

nabi-ebrahimi avatar Jul 09 '26 16:07 nabi-ebrahimi

Proposal

What is the root cause of that problem?

The locked bank account Pay flow opens the global confirm modal from SettlementButton when policy.achAccount.state is LOCKED, but that showConfirmModal() call does not pass shouldDisableConfirmButtonWhenOffline.

https://github.com/Expensify/App/blob/c9f4323e79fa6fe450ee1c109d165b89eb7dbd02/src/components/SettlementButton/index.tsx#L219-L238

ConfirmModal defaults shouldDisableConfirmButtonWhenOffline to false and forwards it to ConfirmContent.

https://github.com/Expensify/App/blob/c9f4323e79fa6fe450ee1c109d165b89eb7dbd02/src/components/ConfirmModal.tsx#L143-L151

https://github.com/Expensify/App/blob/c9f4323e79fa6fe450ee1c109d165b89eb7dbd02/src/components/ConfirmModal.tsx#L212-L225

ConfirmContent already reads useNetwork().isOffline, but it only disables the confirm button when both isOffline and shouldDisableConfirmButtonWhenOffline are true. Because the locked bank account modal leaves the flag false, the Unlock bank account button stays enabled while offline.

https://github.com/Expensify/App/blob/c9f4323e79fa6fe450ee1c109d165b89eb7dbd02/src/components/ConfirmContent.tsx#L160-L164

https://github.com/Expensify/App/blob/c9f4323e79fa6fe450ee1c109d165b89eb7dbd02/src/components/ConfirmContent.tsx#L242-L253

There is also a shared web keyboard path that must stay aligned with the disabled state. ConfirmModalWrapper registers Enter to call handleConfirm() directly, and that wrapper currently does not check whether the confirm action is disabled offline.

https://github.com/Expensify/App/blob/c9f4323e79fa6fe450ee1c109d165b89eb7dbd02/src/components/Modal/Global/ConfirmModalWrapper.tsx#L28-L61

Confirming runs pressLockedBankAccount() and then navigates to Concierge, which seeds the bank account unlock flow and writes optimistic Concierge state, so this action should not be available while offline.

https://github.com/Expensify/App/blob/c9f4323e79fa6fe450ee1c109d165b89eb7dbd02/src/libs/actions/BankAccounts.ts#L1822-L1864

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

Add shouldDisableConfirmButtonWhenOffline: true to the locked-bank-account showConfirmModal() call in SettlementButton. This uses the existing ConfirmContent offline-disable behavior so the Unlock bank account button renders disabled while offline and re-enables when the connection returns.

Also update ConfirmModalWrapper so the same offline-disabled condition blocks handleConfirm() and disables the modal-level Enter shortcut. This keeps the visual disabled state and the underlying confirm action consistent for every confirm modal that explicitly opts into shouldDisableConfirmButtonWhenOffline.

Required tests:

  • Add/update a SettlementButton UI test where the policy ACH account is locked and the network is offline; pressing Pay opens the locked bank account modal and the Unlock bank account button is disabled.
  • Verify the offline modal does not resolve with ModalActions.CONFIRM through click/tap or Enter.
  • Verify the same locked bank account Pay flow still enables the confirm action online.

What alternative solutions did you explore? (Optional)

Only passing shouldDisableConfirmButtonWhenOffline: true in SettlementButton fixes the visible button state, but it leaves the shared ConfirmModalWrapper Enter shortcut able to confirm while offline when focus is not on a button. That is why this proposal is not a duplicate of the one-line caller-only approach.

Guarding pressLockedBankAccount() directly was rejected because the UI would still show an enabled action while offline, which contradicts the expected behavior.

Changing ConfirmContent to disable every confirm button while offline by default was rejected because many confirm modals intentionally allow local or optimistic actions offline.

x-dev90 avatar Jul 09 '26 16:07 x-dev90

⚠️ @x-dev90 Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

github-actions[bot] avatar Jul 09 '26 16:07 github-actions[bot]

Proposal

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

When a workspace's reimbursement bank account is LOCKED, tapping Pay on an approved report opens a "Locked bank account" confirm modal whose confirm button is Unlock bank account. While offline, that button stays enabled and tappable, even though starting the unlock flow needs the server. It should be disabled until the user is back online.

What is the root cause of that problem?

The locked-BA modal is opened from checkForNecessaryAction in SettlementButton via the global showConfirmModal(...), and that call passes only title/prompt/confirmText/cancelText — it never opts into the offline gate the modal already supports:

https://github.com/Expensify/App/blob/89a5c2d4d28d414e51c969fc701b90a496e58f98/src/components/SettlementButton/index.tsx#L219-L239

The confirm button's offline state is entirely driven by shouldDisableConfirmButtonWhenOffline, which defaults to false in ConfirmModal and is forwarded down to ConfirmContent:

https://github.com/Expensify/App/blob/89a5c2d4d28d414e51c969fc701b90a496e58f98/src/components/ConfirmModal.tsx#L151

ConfirmContent is the only place connectivity is checked, and it disables the confirm button only when both flags are true:

https://github.com/Expensify/App/blob/89a5c2d4d28d414e51c969fc701b90a496e58f98/src/components/ConfirmContent.tsx#L252

Because the call site leaves the flag unset, isOffline && false is always false, so the Unlock bank account button never disables offline.

This isn't purely cosmetic. Confirming runs pressLockedBankAccount, which is a raw local Onyx.merge — it drops an optimistic Concierge "unlock requested" comment into the report and seeds INITIATING_BANK_ACCOUNT_UNLOCK:

https://github.com/Expensify/App/blob/89a5c2d4d28d414e51c969fc701b90a496e58f98/src/libs/actions/BankAccounts.ts#L1822-L1864

SettlementButton then navigates the user into Concierge, where useBankAccountUnlockEffect reads that Onyx key and fires the real initiateBankAccountUnlock server write:

https://github.com/Expensify/App/blob/89a5c2d4d28d414e51c969fc701b90a496e58f98/src/hooks/useBankAccountUnlockEffect.ts#L18-L25

So the offline sequence is: tap Unlock → local Concierge comment is written → user is navigated to Concierge and sees it → the server call can't reach the backend, so nothing actually unlocks. The user is left staring at a success-looking message for an unlock that never happened. That's exactly why this button belongs in the "disabled while offline" category.

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

Add one option — shouldDisableConfirmButtonWhenOffline: true — to the showConfirmModal({...}) call in the isBankAccountLocked branch, alongside the existing confirmText/cancelText:

https://github.com/Expensify/App/blob/89a5c2d4d28d414e51c969fc701b90a496e58f98/src/components/SettlementButton/index.tsx#L220-L229

The useConfirmModal → ConfirmModalWrapper → ConfirmModal → ConfirmContent chain already wires this flag to useNetwork().isOffline, so the button renders disabled offline and re-enables the moment connectivity returns — no new component, prop, state, or plumbing. This is the established convention for a confirm that triggers a server write; the security-sensitive "Lock account" and "Close account" modals set the exact same flag:

https://github.com/Expensify/App/blob/89a5c2d4d28d414e51c969fc701b90a496e58f98/src/pages/settings/Security/LockAccount/LockAccountPageBase.tsx#L53-L59

https://github.com/Expensify/App/blob/89a5c2d4d28d414e51c969fc701b90a496e58f98/src/pages/settings/Security/CloseAccountPage.tsx#L41-L48

This is intentionally minimal: it reuses the shared offline-disable block rather than adding a per-action isOffline guard, so online behavior, the Cancel button, and the informational modal text are all untouched (the modal still appears offline — as the test expects — only the Unlock button is disabled).

Note on the Enter key (web): the confirm Button uses pressOnEnter, and its Enter handler runs through validateSubmitShortcut(isDisabled, ...), which returns false when the button is disabled — so this fix also closes the keyboard-confirm path while the confirm button is focused.

https://github.com/Expensify/App/blob/89a5c2d4d28d414e51c969fc701b90a496e58f98/src/components/Button/validateSubmitShortcut/index.ts#L14-L26

However, ConfirmModalWrapper also registers a separate Enter shortcut that calls handleConfirm() directly and is active whenever focus is not on a button (activeElementRole !== CONST.ROLE.BUTTON). That one bypasses isDisabled entirely:

https://github.com/Expensify/App/blob/89a5c2d4d28d414e51c969fc701b90a496e58f98/src/components/Modal/Global/ConfirmModalWrapper.tsx#L55-L61

So on web, if nothing is focused, pressing Enter can still confirm offline. This is a pre-existing, app-wide gap — it already affects the Lock/Close account modals that correctly set the flag — not something this Pay flow introduced, and the reported repro is tap-only on Android/Windows-Chrome, which the one-line fix fully resolves. I'd suggest closing it in the same PR by making the wrapper's Enter shortcut respect the offline-disabled condition (compute props.shouldDisableConfirmButtonWhenOffline && isOffline via useNetwork() and no-op handleConfirm / deactivate the shortcut when true), since that fixes it once for every modal that opts in. If we'd rather keep this issue scoped strictly to the reported symptom, the wrapper change can be tracked separately — happy to go either way.

What alternative solutions did you explore? (Optional)

  • Guard pressLockedBankAccount (or early-return in the .then handler) when offline instead. Rejected — the button would still look enabled and tappable, which is the reported symptom, and it creates a dead control. The codebase consistently expresses "this confirm needs the network" via shouldDisableConfirmButtonWhenOffline, not per-action offline checks.
  • Flip ConfirmContent's default to disable confirm buttons offline everywhere. Rejected — far too broad; most confirm modals wrap purely optimistic actions that are meant to work offline.
  • Suppress the whole modal when offline. Rejected — the modal is informational ("You can't pay this because the bank account is locked…"); the user should still be able to read it offline. Only the Unlock action should be disabled.

Related surfaces worth a follow-up (out of scope here — different entry points/UI, not the reported Pay modal): pressLockedBankAccount is also invoked unguarded from WalletPage (src/pages/settings/Wallet/WalletPage/index.tsx:158), the home-page UnlockBankAccount widget (src/pages/home/TimeSensitiveSection/items/UnlockBankAccount.tsx:44), and WorkspaceWorkflowsPage (src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx:703), so those may have the same offline hole and are worth verifying.

yusufdeveloper2903 avatar Jul 09 '26 16:07 yusufdeveloper2903

Proposal

Problem Statement

When a workspace's reimbursement bank account is in the LOCKED state, pressing Pay on an approved expense report opens a confirmation modal titled "Locked bank account" with an "Unlock bank account" confirm button.

While the device is offline, this confirm button remains enabled and tappable, contrary to Expensify's offline-first convention that network-dependent controls should be disabled while offline. Tapping it ultimately fires the InitiateBankAccountUnlock API command, so it must be disabled offline.

  • Expected: the "Unlock bank account" confirm button is disabled/non-interactive while offline.
  • Actual: the button stays enabled and can be tapped offline.

Root Cause

The modal is opened by checkForNecessaryAction in src/components/SettlementButton/index.tsx. When the policy bank account is locked (isBankAccountLocked = policy?.achAccount?.state === CONST.BANK_ACCOUNT.STATE.LOCKED), it calls showConfirmModal(...):

// src/components/SettlementButton/index.tsx  (~lines 219–240)
if (isBankAccountLocked) {
    showConfirmModal({
        title: translate('bankAccount.lockedBankAccount'),
        prompt: (
            <View style={[styles.renderHTML, styles.flexRow]}>
                <RenderHTML html={translate('bankAccount.youCantPayThis')} />
            </View>
        ),
        confirmText: translate('bankAccount.unlockBankAccount'),
        cancelText: translate('common.cancel'),
        // ⛔ shouldDisableConfirmButtonWhenOffline is NOT passed → defaults to false
    }).then(({action}) => { ... });
    return true;
}

The confirm button's offline state is governed by the shouldDisableConfirmButtonWhenOffline prop, which flows useConfirmModal → ConfirmModalWrapper → ConfirmModal → ConfirmContent. In src/components/ConfirmContent.tsx the button renders as:

// src/components/ConfirmContent.tsx  (lines 252 and 281)
isDisabled={isOffline && shouldDisableConfirmButtonWhenOffline}

shouldDisableConfirmButtonWhenOffline defaults to false (src/components/ConfirmModal.tsx:151, src/components/ConfirmContent.tsx:136). Because the SettlementButton call site omits the flag, the expression collapses to isOffline && false === false, so the button stays enabled offline.

This is a missing opt-in at the call site, not a bug in the shared component — the offline-disable mechanism already exists and works.

Confirming the modal runs pressLockedBankAccount (src/libs/actions/BankAccounts.ts) → navigateToConciergeChat, after which useBankAccountUnlockEffect (src/hooks/useBankAccountUnlockEffect.ts) fires initiateBankAccountUnlock → the InitiateBankAccountUnlock API command. The end of the chain is a server request, so the entry control belongs in the "disabled while offline" category.

Proposed Solution

File: src/components/SettlementButton/index.tsx — function: checkForNecessaryAction.

Add the existing opt-in flag to the showConfirmModal options object in the isBankAccountLocked branch:

 if (isBankAccountLocked) {
     showConfirmModal({
         title: translate('bankAccount.lockedBankAccount'),
         prompt: (
             <View style={[styles.renderHTML, styles.flexRow]}>
                 <RenderHTML html={translate('bankAccount.youCantPayThis')} />
             </View>
         ),
         confirmText: translate('bankAccount.unlockBankAccount'),
         cancelText: translate('common.cancel'),
+        shouldDisableConfirmButtonWhenOffline: true,
     }).then(({action}) => {

That is the entire change — one line.

Why this matches existing architecture

  • Reuses the already-existing offline-disable path (ConfirmContent.tsx:252/281). No new prop, hook, state, or component.
  • Follows the canonical usage established elsewhere:
    • src/pages/settings/Security/LockAccount/LockAccountPageBase.tsx:59 → shouldDisableConfirmButtonWhenOffline: true
    • src/pages/settings/Security/CloseAccountPage.tsx:48 → shouldDisableConfirmButtonWhenOffline: true
  • ConfirmContent already consumes useNetwork().isOffline, so the button re-enables automatically on reconnect.

Why no duplication & low regression risk

  • No offline logic is written at the call site — we only pass a boolean into the shared component that owns that logic.
  • SettlementButton is the only caller of bankAccount.unlockBankAccount (verified by grep), so the change affects a single branch of one function; online behaviour and the cancel button are unchanged.

Alternative Solutions

  1. Flip the default of shouldDisableConfirmButtonWhenOffline to true in ConfirmModal/ConfirmContent. ❌ Inferior — huge blast radius; would wrongly disable purely client-side confirm modals (e.g. local dismissals) that intentionally work offline.
  2. Disable/hide the whole Pay button when locked + offline. ❌ Inferior — the modal is informational ("You can't pay this report because you have a locked bank account…"); suppressing it removes context the user should still be able to read offline. More invasive.
  3. Guard pressLockedBankAccount behind an isOffline check in the .then handler. ❌ Inferior — the button still looks enabled, so it doesn't fix the reported symptom and creates a dead control.

Testing

  • tests/unit/ConfirmContentTest.tsx (already mocks useNetwork): assert that with isOffline: true + shouldDisableConfirmButtonWhenOffline: true the confirm button is disabled, and with the flag omitted it stays enabled (guards against an accidental default flip).
  • tests/ui/components/SettlementButtonTest.tsx: add a case — policy achAccount.state = LOCKED, offline, press Pay, assert the "Unlock bank account" confirm button is disabled. (No offline/locked coverage exists there today, which is how this regression slipped through.)
  • Manual QA: sign in as the locked-BA test account → Airplane mode → open approved report → Pay → verify Unlock button greyed out, Cancel still works, text still readable → reconnect → verify button re-enables and unlock flow proceeds.

Risks

Risk Likelihood Mitigation
Other confirm modals affected None Single option on one call site; shared-component default untouched.
Explanatory text hidden offline None Only the confirm button is disabled; title/prompt/cancel remain.
Button stuck disabled after reconnect Very low ConfirmContent reads live useNetwork().isOffline and re-renders on connectivity change.
Platform divergence None SettlementButton and ConfirmContent are shared (no native overrides on this path).

Why this approach

It activates an offline-disable capability the shared component already implements (reuse over reinvention), mirrors the canonical LockAccountPageBase/CloseAccountPage usage (consistency), upholds the App's offline-first principle, and is a one-line, single-branch change — exactly what a long-term maintainer wants for a targeted UX regression.

intel0725 avatar Jul 09 '26 16:07 intel0725