Skip to content

Migrate remaining ConfirmModal usages to useConfirmModal #100076

Open
6 of 6 issues completed
Open

Description

@roryabraham

Problem

ConfirmModal is deprecated, but origin/main still renders 36 instances across the App codebase. The previous tracker, #76696, covered earlier migration batches and is now deployed.

Solution

Replace the remaining component usages with useConfirmModal, preserving each modal's copy, actions, danger state, focus behavior, and platform-specific behavior. Do not migrate src/components/Modal/Global/ConfirmModalWrapper.tsx as part of the caller inventory; it is the bridge that can be removed after all callers are migrated.

Remaining inventory

  • src/components/AccountingConnectionConfirmationModal.tsx (1)
  • src/components/GPSInProgressModal/index.native.tsx (1)
  • src/components/GPSTripStateChecker/index.native.tsx (1)
  • src/components/MultifactorAuthentication/components/Modals/createCancelConfirmModal.tsx (1)
  • src/components/ScreenShareRequestModal.tsx (1)
  • src/components/UpdateAppModal.tsx (1)
  • src/hooks/useOutstandingBalanceGuard.tsx (1)
  • src/pages/domain/Groups/PreferredWorkspaceToggle.tsx (1)
  • src/pages/domain/Saml/SamlLoginSectionContent.tsx (1)
  • src/pages/DynamicReportParticipantDetailsPage.tsx (1)
  • src/pages/DynamicRoomMemberDetailsPage.tsx (1)
  • src/pages/inbox/report/ContextMenu/PopoverReportActionContextMenu.tsx (1)
  • src/pages/iou/request/step/DynamicIOURequestStepUpgrade.tsx (1)
  • src/pages/iou/request/step/IOURequestEditReportCommon.tsx (1)
  • src/pages/iou/request/step/IOURequestStepDistanceGPS/BackgroundLocationPermissionsFlow/index.android.tsx (3)
  • src/pages/iou/request/step/IOURequestStepDistanceGPS/BackgroundLocationPermissionsFlow/index.ios.tsx (2)
  • src/pages/iou/request/step/IOURequestStepDistanceGPS/GPSButtons/index.tsx (3)
  • src/pages/MultifactorAuthentication/RevokePage.tsx (1)
  • src/pages/settings/Rules/ExpenseRulesPage.tsx (1)
  • src/pages/settings/Wallet/ExpensifyCardPage/index.tsx (2)
  • src/pages/settings/Wallet/UnshareBankAccount/UnshareBankAccount.tsx (2)
  • src/pages/workspace/companyCards/addNew/DynamicAddNewCardPage.tsx (1)
  • src/pages/workspace/copyPolicySettings/CopyPolicySettingsProgressModal.tsx (1)
  • src/pages/workspace/travel/WorkspaceTravelBillingSection.tsx (3)
  • src/pages/workspace/workflows/WorkspaceWorkflowsPayerPage.tsx (2)

Acceptance criteria

  • No remaining direct caller renders ConfirmModal after this migration, apart from ConfirmModalWrapper until it is removed.
  • Confirmation, cancellation, backdrop, focus-management, and navigation behavior remain unchanged.
  • Existing relevant tests pass and coverage is added or updated where needed.
Issue OwnerCurrent Issue Owner: @ZhenjaHorbach

Activity

  1. ZhenjaHorbach commented on Sep 2, 2026

    @ZhenjaHorbach
    Contributor

    @MelvinBot
    Analyze all the modals in the description and check which modals can be migrated and which cannot (for example, by checking comments in the code, why useConfirmModal cannot be used)

  2. MelvinBot commented on Sep 2, 2026

    @MelvinBot
    Contributor

    ConfirmModal migration audit — 35 call-site instances

    32 of 35 can be migrated. 3 cannot without first changing something else. Only one of the three has a written justification in the code today; the other two I found by tracing the call sites.

    Verdicts are static analysis of main at 6bf0775.


    ❌ Cannot be migrated as-is (3)

    Instance Why not What would unblock it
    CopyPolicySettingsProgressModal.tsx:151 The one documented blocker, and it checks out. One isVisible spans two steps (loading → complete), the first confirm re-skins the modal and a second confirm follows, and content also repaints from the bulkPolicyCopySettings NVP with no user action. handleConfirm unconditionally hides, and closeModal pops the modal and deletes its promise — the second confirm is unrepresentable. It's also rendered unconditionally from WorkspacesListPage, so there's no imperative call site to hang showConfirmModal() off. A stable-id "update in place without resolving" path — a multi-resolve/subscription API instead of one-shot Promise.withResolvers.
    PopoverReportActionContextMenu.tsx:540 Three independent problems. (1) hideDeleteModal is exported and called speculatively on unmount from ReportActionItem.tsx:317 even when only the context menu was open — today a harmless no-op, but closeModal() blindly pops the top of the stack and bug-bot-alerts on an empty one. (2) onModalHide nulls reportActionRef.current synchronously before the promise resolves, and that ref is exactly what confirmDeleteAndHideModal reads at :379. (3) Both confirm and cancel install different deferred callbackWhenDeleteModalHide callbacks, plus a mid-confirm redirected bail-out. An id-scoped closeModal(id) that no-ops when that id isn't open, plus a hook to run caller logic before onModalHide.
    createCancelConfirmModal.tsx:24 The component is the config contract — config/types.ts:52 types cancelConfirmation as a component, wired through both scenario configs. Worse, stateReducer.ts force-clears isCancelConfirmVisible in two places with explicit comments ("so it doesn't linger over the outcome screen", "CLOSE_MODAL can close the navigator without the flow ever completing") — declarative auto-hide the one-shot promise can't express. The navigator also returns null at phase === 'closed', unmounting the dialog; a global modal would outlive that. Change types.ts:52 from a component to a props/config object, then migrate the two call sites separately. Note the AuthorizeTransactionPage call site would be trivially migratable on its own — it's only blocked by sharing the factory.

    ✅ Migrate as-is (14)

    Straightforward — user-triggered, confirm/cancel map cleanly onto CONFIRM/CLOSE
    Instance Note
    UpdateAppModal.tsx:24 Onyx flag only ever set true, confirm and cancel are the same handler. Cleanest in the set.
    PreferredWorkspaceToggle.tsx:106 Informational, result can be ignored.
    SamlLoginSectionContent.tsx:131 Already passes shouldHandleNavigationBack — zero behavior delta.
    DynamicIOURequestStepUpgrade.tsx:411 Acknowledgement-only; identical shape to the already-migrated call in IOURequestEditReportCommon.tsx:284.
    IOURequestEditReportCommon.tsx:398 Same file already migrated one call. showConfirmModal isn't referentially stable — don't silently drop it from the validatePerDiemMove dep array.
    GPSButtons/index.tsx:181 Zero-distance ack.
    GPSButtons/index.tsx:207 Early-returns before the child flow starts, so it can never coexist with the permission modals.
    ExpenseRulesPage.tsx:214 Near-identical migrated precedent at WorkspaceMembersPage.tsx:273.
    ExpensifyCardPage/index.tsx:709 & :721 Mutually exclusive by card state. Workspace twin already migrated at DynamicWorkspaceExpensifyCardDetailsPage.tsx:211. Must drop onBackdropPress — see gotchas.
    DynamicAddNewCardPage.tsx:152 Page stays mounted when the modal opens; verified.
    WorkspaceTravelBillingSection.tsx:495, :506, :516 File already uses showConfirmModal at :252. handleToggle early-returns per branch so none can stack. Keep the isCurrencyModalOpen.current guard on the auto-dismiss effect at :314 so it can't pop a newly-migrated modal. :516's title/body become a snapshot instead of live-updating.

    ⚠️ Migrate, but not mechanically (18)

    Each needs a specific restructure — details per instance

    Declarative visibility → needs an effect + ref guard

    • GPSInProgressModal/index.native.tsx:27 — triggered from a non-React action (libs/actions/HybridApp/index.ts:109), so keep the Onyx flag as the cross-boundary trigger and make this a null-rendering controller (idiom exists in PriorityModeController.tsx:63). Stale-closure risk: getGpsPoints(gpsDraftDetails) would capture points at show time while tracking keeps appending — read via refs.
    • GPSTripStateChecker/index.native.tsx:145 — closest to blocked. isVisible is a 4-term derived expression; three terms can flip while open and today the modal auto-hides for free. Also onCancel={onViewTrip} stops the trip — collapsing cancel+backdrop into one CLOSE, plus the default shouldHandleNavigationBack: true, would route hardware-back into a destructive action. Pass shouldHandleNavigationBack: false. tests/unit/components/GPSTripStateCheckerTest.tsx will need updating.
    • ScreenShareRequestModal.tsx:25 — no auto-hide needed (both branches clear the Onyx key), but GlobalModals.tsx:65 documents a DOM-order stacking invariant putting UpdateAppModal on top. Migrating this one alone inverts it — migrate it together with UpdateAppModal.
    • UnshareBankAccount.tsx:175 — dismissal semantics change. Today onCancel is undefined, so backdrop and ESC are no-ops and the only exit runs clearUnshareBankAccountErrors. After migration CLOSE becomes reachable, so you must clear the errors on both CONFIRM and CLOSE — otherwise the Onyx error stays set, the effect dep never flips, and the modal can never be re-shown. Needs an isFocused guard too (precedent: DeleteWorkspaceFlow.tsx:139).

    Component/hook API ripple

    • AccountingConnectionConfirmationModal.tsx:22 — single caller (AccountingContext/index.tsx:183), so delete the wrapper and call from startIntegrationFlow. But shouldShowConfirmationModal also gates the renderActiveIntegration() branch — that flag must survive.
    • useOutstandingBalanceGuard.tsx:41 — the hook returns a React element that is its consumer's entire output (DeleteWorkspaceFlow.tsx:317). Drop it from the return and make that return null; same file already uses showConfirmModal at :145/:206.
    • WorkspaceWorkflowsPayerPage.tsx:357 & :381 — the RenderHTML prompt's onLinkPress does close-then-navigate. Once local isVisible is gone that callback must call closeModal(), which isn't currently destructured at :99. A real rewrite, not a prop move. (This file proves ReactNode prompts work through the wrapper — :255.)

    Chained flows — open the next modal from the resolved promise, not synchronously

    • index.android.tsx:115, :133, :151 — sequential, never simultaneous, so the top-of-stack rule isn't hit. Native permission prompts move from press-time to one hide-animation later; worth a device pass.
    • index.ios.tsx:119 & :140 — migration is a net improvement here. The onModalHide ref hack at :93/:112/:135 exists because "can't trigger Precise Location modal before First Ask modal hides / the animations clash". The global promise already resolves after hide, so the ref, the useRef and the onModalHide prop can all be deleted. It also likely fixes a latent bug: onModalHide.current is only assigned after the user answers up to two native dialogs, so if the hide animation finishes first the precise-location modal never appears. Worth confirming on device.
    • GPSButtons/index.tsx:189 — shown via the child's onDeny, which sits in the child's effect dep array. Fine as-is; re-derive if the child becomes a hook.
    • UnshareBankAccount.tsx:188 — chains into :175. Safe only in the awaited continuation; pushing it synchronously from onConfirm strands this modal under the next one.

    Timing / async

    • RevokePage.tsx:244 — passes isConfirmLoading, so it takes the wrapper's async branch: the promise resolves but the modal stays open until you call closeModal(). All three hideConfirmModal() calls must become closeModal(). Precedent: DeleteWorkspaceFlow.tsx:212. (Don't copy LockAccountPageBase.tsx:54 — it passes isConfirmLoading and never closes, which looks like a latent leak.)
    • DynamicReportParticipantDetailsPage.tsx:120 & DynamicRoomMemberDetailsPage.tsx:113 — structurally identical. removeFromGroupChat/removeFromRoom + goBack currently fire synchronously on press; after migration they run after the hide animation.

    Cross-cutting gotchas for whoever picks this up

    Five things that bite regardless of which instance you touch
    1. onBackdropPress must be deleted, not forwarded. The wrapper omits only onConfirm/onCancel/isVisible, so onBackdropPress spreads through to BaseModal, which prefers it over onClose. The wrapper's handleCancel then never runs — the modal never hides and the promise never resolves. Affects both ExpensifyCardPage instances (both handlers are byte-identical to onCancel, so dropping them is behavior-preserving).
    2. shouldHandleNavigationBack silently flips undefined → true (useConfirmModal.ts:17). Most instances leave it unset today, so migrating adds a history/back guard. Pass it explicitly where that matters.
    3. A global ENTER shortcut gets registered (ConfirmModalWrapper.tsx:66). For destructive DANGER confirms (delete comment, remove member) that makes Enter a one-keystroke destructive action where it previously wasn't.
    4. closeModal() is not id-scoped — it pops whatever is on top (ModalContext.tsx:111) and bug-bot-alerts on an empty stack. This is the root of the PopoverReportActionContextMenu block and a hazard for every auto-hide conversion.
    5. Props become a snapshot. Anything interpolated into title/prompt from Onyx is captured at show time instead of updating live. Relevant to WorkspaceTravelBillingSection:516 (formattedSpend) and the GPS modals (gpsDraftDetails), where the stale value would be submitted.

    Suggested order: the 14 clean ones first (they establish the pattern and shrink the surface), then the 18 with-care ones grouped by theme, and file the 3 blockers as follow-ups — the createCancelConfirmModal and PopoverReportActionContextMenu ones both need a small API change to the global modal system (closeModal(id)) or to the MFA scenario config before they're even in scope.

    One caveat: this checkout is a shallow clone, so I couldn't check whether any of these had a migration attempt previously reverted. Worth a quick PR search if any verdict here surprises you.


    Next Steps: Reply with @MelvinBot <your feedback> to refine this analysis.


    view run

  3. ZhenjaHorbach commented on Sep 2, 2026

    @ZhenjaHorbach
    Contributor

    @MelvinBot
    Can you create 5 or 6 sub-issues for migrating these modals?
    With approximately the same migration complexity

  4. MelvinBot commented on Sep 2, 2026

    @MelvinBot
    Contributor

    Created 6 sub-issues covering the 32 migratable instances, balanced by effort rather than by file count. The 3 blockers from my earlier analysis are deliberately excluded.

    Sub-issue Modals Theme Why grouped
    #100151 7 Simple user-triggered confirms All map cleanly onto CONFIRM/CLOSE with existing precedents. The two remove-member pages are near-identical to each other.
    #100152 6 Workspace travel, workflows, company cards Two of three files already call showConfirmModal() in-file. Four drop-ins plus two onLinkPress rewrites.
    #100153 5 Wallet + MFA settings Two drop-ins with a migrated twin to copy, plus three specific traps: dismissal semantics, chaining, and the isConfirmLoading contract.
    #100154 4 Onyx-driven app-level modals All four have declarative visibility, so all four need the same controller-style rewrite. UpdateAppModal and ScreenShareRequestModal must ship together — there's a stacking invariant between them.
    #100155 5 Background location permissions flow One chained state machine split across .android/.ios. Can't be split further; each modal opens from the previous one's outcome.
    #100156 5 GPS trip modals Three easy GPSButtons confirms balance out the two hardest instances in the migration (GPSTripStateChecker, GPSInProgressModal).

    I weighted each instance 1 for a clean drop-in and 2 for one needing a restructure. Batches came out at 9, 8, 8, 7, 10, 8 — close enough that any of them is a comparable PR.

    Excluded (3): CopyPolicySettingsProgressModal, PopoverReportActionContextMenu, and createCancelConfirmModal. Each needs an API change first — an id-scoped closeModal(id), a multi-resolve modal API, or a change to the MFA scenario-config contract. Tell me if you want those filed as follow-ups too; I left them off since they aren't migration work.

    Two things I decided rather than guessed, so flag either if you'd rather go the other way:

    • Labelled them Weekly only, to match this tracker. I didn't add External — making them contributor-eligible triggers the payment flow, which is your call.
    • Left them unassigned.

    Each body carries the per-instance notes, permalinks at 6bf0775, the shared gotchas, and acceptance criteria, so a contributor can pick one up without reading this thread.


    view run

  5. ZhenjaHorbach commented on Sep 2, 2026

    @ZhenjaHorbach
    Contributor

    @MelvinBot
    Assign me and @roryabraham to these issues

  6. MelvinBot commented on Sep 2, 2026

    @MelvinBot
    Contributor

    Done — you and roryabraham are now assigned to all six sub-issues.

    Issue Assignees
    #100151 ZhenjaHorbach, roryabraham
    #100152 ZhenjaHorbach, roryabraham
    #100153 ZhenjaHorbach, roryabraham
    #100154 ZhenjaHorbach, roryabraham
    #100155 ZhenjaHorbach, roryabraham
    #100156 ZhenjaHorbach, roryabraham

    Verified after the edits. This tracker already had you both assigned, so I left it alone.


    view run

  7. melvin-bot commented on Sep 25, 2026

    @melvin-bot

    This issue has not been updated in over 15 days. @roryabraham, @ZhenjaHorbach eroding to Monthly issue.

    P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions