Consolidate ConfirmModal instances into a global component#68190
Consolidate ConfirmModal instances into a global component#68190roryabraham merged 21 commits intoExpensify:mainfrom
Conversation
|
|
07f62af to
04a86f1
Compare
1ef6a86 to
c19f9e3
Compare
ac7254e to
370a380
Compare
370a380 to
f8d9184
Compare
|
@alitoshmatov 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] |
roryabraham
left a comment
There was a problem hiding this comment.
Thanks in advance for your patience as we work through this review - while I'm sure this works well as written, I want to establish really clear and solid patterns for global shared modals. So I might just want to collaboratively iterate on this a bit, and I'm sure the end result is going to be great.
First piece of feedback is that I don't think PromiseModal is a great name, mostly because it over-emphasizes an implementation detail.
I don't love dumping AI-generated review notes, but after chatting in cursor a bit, I actually really liked its suggestion for directory structure and naming conventions:
Based on my examination of the current modal structure, I can see there are three main types of modals:
- Standard/Legacy Modal - Traditional modals where each component manages its own modal state
- ReanimatedModal - Specialized animated modals using React Native Reanimated
- PromiseModal - The new global/shared modal system using React Context and promises
Here's my proposed directory structure and naming convention:
Proposed Directory Structure
src/components/Modal/
├── Core/ # Core modal components and types
│ ├── BaseModal.tsx
│ ├── ModalContent.tsx
│ ├── types.ts
│ ├── index.tsx
│ ├── index.ios.tsx
│ └── index.android.tsx
│
├── Animated/ # Reanimated-based modals
│ ├── index.tsx
│ ├── types.ts
│ ├── utils.ts
│ ├── Container/
│ │ ├── index.tsx
│ │ ├── index.web.tsx
│ │ └── GestureHandler.tsx
│ └── Backdrop/
│ ├── index.tsx
│ └── index.web.tsx
│
├── Global/ # Global/shared modal system
│ ├── ModalProvider.tsx # Previously ModalContext.tsx
│ ├── useModal.tsx # Basic modal hook
│ ├── useConfirmModal.tsx # Previously useModalHook.tsx
│ ├── ConfirmModalWrapper.tsx # Wrapper for confirm dialogs
│ ├── types.ts # Modal-specific types
│ └── index.ts # Exports
│
└── index.ts # Main modal exports
Naming Convention Changes
Core Components
Modal→ Keep as main export (from Core/)ReanimatedModal→AnimatedModal(from Animated/)PromiseModalProvider→ModalProvider(from Global/)
Hooks
useModal→ Keep as the main global modal hookuseConfirmModal→ Keep as the convenience hook for confirmationsusePromiseModal→ Remove this alias, just useuseModal
Types
PromiseResolvePayload→ModalResolvePayloadorModalResultModalAction→ Keep as-isModalInfo→ Keep as-is but move to Global/types.ts
Benefits of This Structure
- Clear Separation of Concerns: Each directory has a specific purpose
- Intuitive Naming: Names describe what the component does, not how it's implemented
- Better Discoverability: Developers can easily find the right modal type for their use case
- Consistent with React Patterns: Global state management is clearly identified
- Future-Proof: Easy to add new modal types or deprecate old ones
Import Examples
// Legacy/one-off modals
import Modal from '@components/Modal';
// Animated modals
import AnimatedModal from '@components/Modal/Animated';
// Global modal system
import {ModalProvider, useModal, useConfirmModal} from '@components/Modal/Global';
// Or if you prefer the shorter version:
import {ModalProvider, useModal, useConfirmModal} from '@components/Modal';The Global/ directory name clearly indicates this is the shared modal system, while Core/ contains the foundational modal components that the other systems might build upon.
| shouldReverseStackedButtons = false, | ||
| isConfirmLoading = false, | ||
| }: ConfirmModalWrapperProps) { | ||
| const handleConfirm = () => { |
There was a problem hiding this comment.
Would suggest memoizing these with useCallback but I have no basis to know whether React Compiler will do it automatically
|
Working on it |
|
Almost done with the review, @zirgulis can you resolve the conflicts, thanks |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppconfirm-android.movAndroid: mWeb Chromeconfirm-mweb.moviOS: HybridAppconfirm-ios.mp4iOS: mWeb Safariconfirm-safari.mp4MacOS: Chrome / Safariconfirm-web.movMacOS: Desktopconfirm-desktop.mov |
…to ft/promise-modal
|
@alitoshmatov merge conflicts are fixed, please review the changes |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/roryabraham in version: 9.2.1-0 🚀
|
|
@zirgulis @trjExpensify "Export again" modal can be triggered by exporting again with the accounting software only, but not whithout accounting connected. Could you provide more detailed steps for the Export Again Modal. bandicam.2025-09-04.10-07-32-428.mp4bandicam.2025-09-04.10-19-27-011.mp4 |
|
@jponikarchuk From the code I see that
So I think your reported behavior is expected, correct me if I'm wrong @trjExpensify |
|
I think what @jponikarchuk is saying is that these tests are a bit confusing because they don't specify that it's a modal triggered after re-exporting a report to an accounting solution. 👍
|
|
🚀 Deployed to production by https://github.com/arosiclair in version: 9.2.1-20 🚀
|
|
🚀 Deployed to staging by https://github.com/roryabraham in version: 9.2.2-0 🚀
|
…t/promise-modal" This reverts commit 5953b32.
…t/promise-modal" This reverts commit 5953b32.
|
🚀 Deployed to production by https://github.com/francoisl in version: 9.2.2-8 🚀
|
…t/promise-modal" This reverts commit 5953b32.
|
🚀 Deployed to staging by https://github.com/roryabraham in version: 9.2.15-0 🚀
|
|
🚀 Deployed to production by https://github.com/Beamanator in version: 9.2.15-15 🚀
|

Explanation of Change
Currently the app suffers from component bloat in regards to
ConfirmModalinstances. Reduce the memory footprint and simplify working with modals by consolidatingConfirmModalinstances into a single component instance.Fixed Issues
$ #68799
Tests
a. Navigate to an expense report
b. Click "Export" → Select any export template
c. Verify: Export progress modal shows with "Export in progress" message
d. Verify: Modal cannot be cancelled (no cancel button)
e. Verify: Promise resolves correctly and clears selected transactions
A. Unapprove Report
a. Go to an approved, exported report
b. Click "More" → "Unapprove"
c. Verify: Warning modal appears about integration export
d. Click "Unapprove Report"
e. Verify: Report gets unapproved successfully
f. Test Cancel: Try again and click "Cancel" - verify nothing happens
B. Cancel Payment
a. Go to a report with pending payment
b. Click "More" → "Cancel Payment"
c. Verify: Confirmation modal appears
d. Click "Cancel Payment"
e. Verify: Payment is cancelled
f. Test Cancel: Try again and click "Dismiss" - verify nothing happens
C. Delete Report/Expenses
a. Go to report with single expense
b. Click "More" → "Delete"
c. Verify: Delete confirmation modal
d. Click "Delete" → Verify: Expense deleted and navigation works
a. Go to report with multiple expenses
b. Click "More" → "Delete"
c. Verify: Different modal text for multiple expenses
d. Click "Delete" → Verify: Entire report deleted
D. Reopen Exported Report
a. Go to closed, exported report
b. Click "More" → "Reopen Report"
c. Verify: Warning modal about reopening exported report
d. Click "Reopen Report"
e. Verify: Report reopens successfully
Selected Transactions Delete
a. Go to expense report
b. Select multiple transactions
c. Click bulk actions → "Delete"
d. Verify: Delete confirmation with count
e. Verify: After deletion, navigation handles correctly
Export Again Modal
a. Try to re-export an already exported report
b. Verify: "Export Again" modal appears
c. Click "Export Again"
d. Verify: Export proceeds
For each modal above, please test:
Offline tests
QA Steps
Same as in "Tests" section
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.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
Screen.Recording.2025-08-26.at.17.12.31.mov
Android: mWeb Chrome
Screen.Recording.2025-08-26.at.17.29.02.mov
iOS: Native
Screen.Recording.2025-08-26.at.16.47.39.mov
iOS: mWeb Safari
Screen.Recording.2025-08-26.at.17.31.37.mov
MacOS: Chrome / Safari
Screen.Recording.2025-08-26.at.16.51.13.mov
MacOS: Desktop
Screen.Recording.2025-08-26.at.17.50.23.mov