Repository navigation
[Batch 1] Migrate seven simple ConfirmModal call sites to useConfirmModal - #100285
Conversation
Co-authored-by: Yauheni Horbach <ZhenjaHorbach@users.noreply.github.com>
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
There's nothing to fix — all code checks pass. The only red check is Check independent approval, which is a human review gate, not a code failure. Its Full check resultsPassing (34): Failing (1): Skipped (8): Some checks (ESLint, the Jest shards, and the Reassure perf suite) were still queued when this run started; I waited for them to finish before concluding. They all passed. Separately, the |
|
🤖 Web test steps verification results: The
Not covered — four of the seven migrated call sites are unreachable on a fresh non-domain, non-SAML test account: Copy observation, not a regression: |
| return true; | ||
| } | ||
| setPerDiemWarningModalVisible(true); | ||
| // Acknowledgement only — the result is intentionally ignored because there is no cancel action. |
There was a problem hiding this comment.
@MelvinBot
Remove this comment because it does not contain useful information
There was a problem hiding this comment.
Removed in bef0984.
I also removed the two other identical comments on this PR (DynamicIOURequestStepUpgrade.tsx and PreferredWorkspaceToggle.tsx) since they said the same thing.
npm run typecheck, ESLint, the React Compiler compliance check, and tests/ui/IOURequestEditReportCommonTest.tsx (7/7) all pass.
| const onUpgrade = () => { | ||
| if (isRestrictedPolicyCreation) { | ||
| setIsUpgradeWarningModalOpen(true); | ||
| // Acknowledgement only — the result is intentionally ignored because there is no cancel action. |
There was a problem hiding this comment.
@MelvinBot
Remove this comment because it does not contain useful information
There was a problem hiding this comment.
| disabled={!hasAdminPolicies && !isEnabled} | ||
| disabledAction={() => setIsNoWorkspacesModalVisible(true)} | ||
| disabledAction={() => { | ||
| // Informational only — the result is intentionally ignored because confirm and cancel do the same thing. |
There was a problem hiding this comment.
@MelvinBot
Remove this comment because it does not contain useful information
There was a problem hiding this comment.
Removed in bef0984, along with the two identical comments on IOURequestEditReportCommon.tsx and PreferredWorkspaceToggle.tsx.
npm run typecheck, ESLint, the React Compiler compliance check, and tests/ui/IOURequestEditReportCommonTest.tsx (7/7) all pass.
Co-authored-by: Yauheni Horbach <ZhenjaHorbach@users.noreply.github.com>
|
@MelvinBot |
|
@ZhenjaHorbach Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
Done — the PR body is filled in and the PR is out of draft. Test steps. Seven numbered flows, one per migrated call site, plus a shared block of checks that applies to all of them (copy unchanged, red button on the destructive ones, backdrop/Escape dismiss, browser-back dismisses instead of navigating, Enter confirms, no console errors). Browser verification. I ran tests 1 and 6 on dev NewDot web against this branch. Both pass — the dialog opens with the right copy and button variants, Cancel is a no-op, Confirm performs the action and navigates. The bulk delete correctly switches to plural copy for two selected rules. Screenshots are in the Boxes I left unchecked, and why:
Two more assertions in my test run were untestable for the same tooling reason: browser-back dismissal and Escape dismissal. Browser-back is worth a deliberate human pass, since the Everything else is checked. The Because several boxes are honestly unchecked, the view run · no recording available |
|
@MelvinBot |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bef0984483
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| deleteExpenseRules(expenseRules, selectedRules, getKeyForRule); | ||
| const handleDeleteRules = (rulesToDelete: string[]) => { | ||
| if (rulesToDelete.length > 0) { | ||
| deleteExpenseRules(expenseRules, rulesToDelete, getKeyForRule); |
There was a problem hiding this comment.
Read current rules before applying the confirmed deletion
When NVP_EXPENSE_RULES changes while this global modal is open—for example, because a pending request completes or another device updates the rules—the promise callback retains this render's stale expenseRules array while deliberately retaining the old selection. deleteExpenseRules() then uses Onyx.set and sends the entire rule collection derived from that stale snapshot, potentially erasing newly added or edited rules; previously the rerendered callback observed the cleared selection and aborted. Preserve only stable rule identities and resolve them against the current collection at confirmation time, or cancel the deletion when the collection changes.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch — this is a real regression the migration introduced. Fixed in 8b40fb8.
Before the migration, onConfirm ran synchronously from a fresh render, so the effect that clears selectedRules on every NVP_EXPENSE_RULES change had already emptied the selection and handleDeleteRules aborted. The promise closure removed that safeguard: it holds both the old selection and the old expenseRules, and deleteExpenseRules Onyx.sets the whole collection derived from that array — so a concurrent update would be clobbered.
I went with your second suggestion (cancel when the collection changes) rather than the first. Re-resolving the keys against the current collection isn't safe here: keyForList is ${hash}-${index}, so the indices are only meaningful against the snapshot they came from — remapping them onto a changed collection could delete the wrong rows.
A ref tracks the live collection, and the confirm callback drops the deletion if it no longer matches the snapshot taken at show time, clearing the selection exactly as before:
if (latestExpenseRulesRef.current !== expenseRulesWhenShown) {
handleDeleteRules([]);
return;
}One incidental change came with it: headerDropdownOptions is now built as an array literal with a spread instead of unshift. The react-hooks/refs rule rejects passing an object graph containing a ref-reading callback into a function call during render, so the mutation had to go. Option order is unchanged (Edit above Delete).
npm run typecheck, ESLint, the React Compiler compliance check, and cspell all pass, plus 25 tests across four related suites.
|
@MelvinBot |
…ModalBatch1 Co-authored-by: Yauheni Horbach <ZhenjaHorbach@users.noreply.github.com>
|
The ESLint failure is not caused by this PR — it came in from What's failing: Root cause: #99420 (merged to Your merge of Fix (belongs in its own PR against categoriesToMatch: [],
ruleType: CONST.POLICY.EXPENSE_DEFAULT_RULE_TYPE.MERCHANT,Better still, drop the Evidence
The other two red checks are Everything else is green: typecheck, Oxfmt, spellcheck, React Compiler Compliance, all 8 Jest jobs, Bun tests, Storybook, perf tests, and both builds. |
|
The ESLint failure is broken The error: That file is not in this PR's diff, and its blob is byte-identical to Evidence that it's pre-existing on mainCause. #99420 merged to Timeline.
Ruling out this PR. The only Reproduced locally. The other two failures need a human, not a push:
Every other check passes: typecheck, Oxfmt, spellcheck, React Compiler Compliance, all 8 Jest jobs, Bun tests, Storybook, perf tests, and both builds. |
|
@MelvinBot |
…ModalBatch1 Co-authored-by: Yauheni Horbach <ZhenjaHorbach@users.noreply.github.com>
|
Branch updated with the latest GitHub now reports the PR as Checks re-run against the merged branch:
No dependency changes came in with the merge ( Note on one skipped checkPrettier couldn't run in this environment — it resolved a config outside the App checkout and failed to load view run · no recording available |
|
MelvinBot has made 5 consecutive commits trying to fix CI failures. Automatic CI fix dispatches are now paused for this PR. Next steps: A human should review the recent commits and resolve the conflicting CI errors manually. |
|
@MelvinBot |
…ModalBatch1 # Conflicts: # config/eslint/eslint.seatbelt.tsv
|
Conflicts fixed — merged The only conflict was How the seatbelt conflict was resolvedThis PR's only change to the seatbelt file versus the merge base ( Verified with
Post-merge checks
Two caveats worth knowing:
The full Jest suite and Prettier were not run locally, same as before. No re-testing of the UI flows was needed: the merge introduced zero changes to the seven migrated files, so the manual |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 roryabraham has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/roryabraham in version: 9.4.75-0 🚀
|
|
🤖 No help site changes are required. No draft PR was created. This PR is an internal refactor only: it swaps seven declarative What I checkedNo user-facing copy changed. Each migrated call site passes the same keys it passed before — for example No flow, label, or navigation path changed. The changed files are 7 page components, The affected flows that the help site does document are still accurate. articles/new-expensify/settings/Personal-Expense-Rules.md:79-80 documents the rule deletion flow as "Select Delete rule(s)" then "Confirm deletion" — both still correct after this change. The group-chat member removal, room member removal, SAML required toggle, per diem move warning, and the restricted-workspace upgrade warning are not documented as step-by-step flows in The one behavior delta is not documented anywhere. Browser back now dismisses these dialogs instead of navigating away, and Enter now confirms them. The help site does not describe keyboard or browser back button behavior for confirmation dialogs, so there is no article to correct. @ZhenjaHorbach, there is no linked help site PR to review or mark |
|
This PR failing because of the issue #100794 |
But as far as I can see, modals aren't even being used here 😁 |
|
QA team is having trouble executing steps 6 and 7. |
Unfortunately, I used mocks |
|
@zanyrenney can you test it internally in this case? |
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.4.75-3 🚀
Bundle Size Analysis (Sentry): |
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.4.75-3 🚀
Bundle Size Analysis (Sentry): |

















Explanation of Change
Batch 1 of the
ConfirmModal→useConfirmModal()migration.ConfirmModalis deprecated; these seven call sites are the mechanical ones, where confirm/cancel map directly onto theCONFIRM/CLOSEactions returned byshowConfirmModal().Each migration replaces a declaratively-rendered
<ConfirmModal isVisible={...}>plus itsuseStatevisibility flag with an imperativeshowConfirmModal()call in the handler that used to flip that flag.PreferredWorkspaceToggle.tsxSamlLoginSectionContent.tsxshouldHandleNavigationBack, kept explicit — zero delta on that prop.DynamicIOURequestStepUpgrade.tsxisUpgradeWarningModalOpenandhandleConfirmUpgradeWarningare now dead code and removed.IOURequestEditReportCommon.tsxExpenseRulesPage.tsxWorkspaceMembersPage.tsx.DynamicReportParticipantDetailsPage.tsxremoveFromGroupChat+goBacknow run after the hide animation instead of synchronously.DynamicRoomMemberDetailsPage.tsxconfig/eslint/eslint.seatbelt.tsvdrops the seven now-resolved@typescript-eslint/no-deprecated/ConfirmModalentries.Decisions worth a reviewer's attention
shouldHandleNavigationBackis left at the hook's default (true) for the six sites that never passed it. The hook flipsundefined→true, so this is a real delta: browser back now dismisses the dialog instead of navigating away. That is the correct behavior for a global modal — it is rendered byModalProviderand outlives the page that opened it, so passingfalsewould leave an orphaned dialog on top of the next screen. This also matches the already-migrated acknowledgement modal inIOURequestEditReportCommon.tsx, which the issue cites as the precedent.ExpenseRulesPagecaptures the selection at show time. The effect that clearsselectedRuleson every Onyx change means the.then()closure holds the pre-open selection rather than readingselectedRulesat confirm time.handleDeleteRulesnow takes the rule list as a parameter to make that explicit.ConfirmModalWrapper. For the twoDANGERremove-member dialogs this makes Enter a one-keystroke destructive confirm, where previously it was not. This is inherent to the wrapper and matches the already-migratedWorkspaceMembersPageremove-members dialog, but flagging it since it is a behavior change.onBackdropPressto drop. None of the seven passed it, so the wrapper's spread hazard does not apply here.AI Tests
Run locally against this branch:
npm run typechecknpm run lint-changednpm run spell-changednpm run react-compiler-compliance-check check <7 changed files>npm test -- tests/ui/IOURequestEditReportCommonTest.tsxtests/ui/IOURequestEditReportCommonTest.tsxis the only suite in the repo that touches any of these seven files. It already mockeduseConfirmModal, so it covers the migrated call directly; I added one case asserting the per diem move warning is raised throughshowConfirmModaland thatselectReportis not called.The full Jest suite (1335 files) and Prettier were not run locally — CI covers both.
Automated browser verification
Tests 1 and 6 below were driven on dev NewDot web against this branch. Both flows pass: the dialog opens with the correct copy and button variants, Cancel is a no-op, and Confirm performs the action and navigates. Singular/plural copy on the bulk delete is correct.
Three assertions could not be exercised because the web automation backend used for this run exposes no history-back, key-press, or console-log primitive: browser Back dismissal, Escape dismissal, and console-error capture. Those still need a human pass. As a partial proxy for the last one, a network dump over the whole run showed only HTTP 200s and no failed requests.
Fixed Issues
$ #100151
PROPOSAL:
Tests
This PR changes how seven confirmation dialogs are invoked, not what they say or do. So every test below is the same shape: open the dialog, check the copy and buttons match what shipped before, check Cancel is a no-op, check Confirm still performs the action.
Applies to every dialog in tests 1–7 — check these each time:
main.Escape, dismisses it and performs no action.Enterwhile the dialog is open triggers the confirm action.1. Delete an expense rule —
ExpenseRulesPage.tsx/settings/rules).2. Remove a member from a group chat —
DynamicReportParticipantDetailsPage.tsx<name>?" with a red Remove and a Cancel.3. Remove a member from a workspace room —
DynamicRoomMemberDetailsPage.tsx4. Per diem move warning —
IOURequestEditReportCommon.tsx5. Restricted policy creation warning —
DynamicIOURequestStepUpgrade.tsx6. Preferred workspace toggle with no admin workspaces —
PreferredWorkspaceToggle.tsx7. Disable SAML required with Okta SCIM enabled —
SamlLoginSectionContent.tsxOffline tests
These dialogs are pure client-side UI — they do not wait on the network to open or close. What changes offline is only the action behind the confirm button, and that behavior is unchanged by this PR.
QA Steps
Same as the Tests section above.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Test 1 — delete an expense rule
Dialog opens with the correct copy and a red Delete button:
After confirming, the rule is gone:
With two rules selected, the copy switches to the plural form:
Test 2 — remove a member from a group chat
Dialog opens with the member's name and a red Remove button:
After confirming, the member is removed and the app navigates back to the members list: