Repository navigation
refactor: read src/pages/iou (3/3) Onyx data in event handlers with Onyx.get - #106706
Conversation
|
@MelvinBot deep review |
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Deep review: 1 findingP2 — Update the report-picker test for asynchronous selectionThe new The test fails reproducibly: expected 1 call, received 0. Update it to await asynchronous Validation: 88 targeted tests passed; 1 failed. Reviewed all changed files, including selector equivalence, Search snapshot compatibility, billing restrictions, and navigation/write ordering. No additional concrete functional regressions found. Limitations: No browser/native verification or full-suite run. Running the failing test against the base revision was blocked by environment permissions. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6d285a81e6
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return; | ||
| } | ||
|
|
||
| const [quickAction, reportTransactionsAndViolations] = await Onyx.multiGet([ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, ONYXKEYS.DERIVED.REPORT_TRANSACTIONS_AND_VIOLATIONS]); |
There was a problem hiding this comment.
Lock Pay submission before awaiting Onyx
If a valid pay is activated twice while this multiGet is pending, both invocations pass the isConfirmed guard above while it is still false. The direct paths only set that state inside sendMoney, and the dismiss-first path sets it later, so both continuations can issue separate send-money writes; take a synchronous submit lock before yielding.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Could't repro. The read can’t be interleaved. Onyx.multiGet resolves from the cache in microtasks, so a second tap runs after the first handler has already finished. The pay option is also a popover item that fires after the modal hides, so a second activation needs a second selection
| const isFromGlobalCreate = getIsFromGlobalCreate(transaction); | ||
|
|
||
| const firstReceiptFile = files.at(0); | ||
| const [quickAction, policyRecentlyUsedCurrencies, activePolicyID, recentWaypoints, userLocation, onboarding, transactionDrafts, conciergeChat] = await Onyx.multiGet([ |
There was a problem hiding this comment.
Lock scan submission before awaiting Onyx
In MultiScan, the receipt Submit button remains enabled after capture while this read is pending. A second tap re-enters submitDirectly; each invocation has already generated fresh optimistic transaction IDs, so both can submit the same receipt batch as separate expenses. Add a synchronous in-flight guard before awaiting.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Same reasoning as previous one. The read resolves in microtasks before any later tap can run. The old handler was synchronous with no in-flight guard either, and the button stayed tappable until the screen left, so this adds no new exposure
| const navigateToNextStep = () => { | ||
| const navigateToNextStep = async () => { | ||
| const [lastSelectedDistanceRates, quickAction, policyRecentlyUsedCurrencies, recentWaypoints, rules, introSelected, allTransactionDrafts, onboarding, conciergeChat] = | ||
| await Onyx.multiGet([ |
There was a problem hiding this comment.
Lock GPS save while the Onyx snapshot is pending
For a new GPS request, Save remains enabled while this read is pending. Two taps before it resolves can each reach handleMoneyRequestStepDistanceNavigation; on a quick-action path that skips confirmation, both continuations submit a distance request, creating two expenses for one trip. Guard the submission before yielding.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Same reasoning as previous one. The multiGet finishes before a second tap runs, and the old handler had no guard, so behavior is unchanged
| allTransactionDrafts, | ||
| onboarding, | ||
| conciergeChat, | ||
| ] = await Onyx.multiGet([ |
There was a problem hiding this comment.
Lock odometer submission while the Onyx read is pending
In create mode, Next remains enabled while this read is pending. A second tap can start another navigation, and on a quick-action path that skips confirmation each call can submit a separate mileage expense. Take a synchronous submit lock before awaiting.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Same as above. The old handler was synchronous with no guard, and the new read resolves before a second tap can run
|
@MelvinBot review |
|
No new findings on
No browser verification or full-suite run performed. |
|
@TaduJR @aimane-chnaif One of you needs to 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] |
|
No product review needed. |
|
|
||
| /** Caller-provided send-money handler for pay flows */ | ||
| onSendMoney?: (paymentMethod: PaymentMethodType | undefined) => void; | ||
| onSendMoney?: (paymentMethod: PaymentMethodType | undefined) => void | Promise<void>; |
There was a problem hiding this comment.
This is a strange type signature to me. Is there any downside to making it always return a promise?
There was a problem hiding this comment.
I did the same for the other slots that only get an async handler. The shared removeFromReport prop in IOURequestEditReportCommon stays void | Promise<void>, because two callers pass a sync function and it would cause error TS2322: Type '() => void' is not assignable to type '() => Promise<void>'.
|
This PR adds a new |
|
@aimane-chnaif are you still reviewing this one? |
|
yes but since new commits pushed, doing final test shortly... |
|
Merging since @chuckdries had already approved |
|
🚧 luacmartins 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! 🧪🧪
|
|
✋ 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/luacmartins in version: 9.5.43-0 🚀
|
|
No help site update needed — this PR refactors internal data reads without adding features, changing user-facing workflows or labels, removing beta gates, or making existing article instructions incorrect. |
|
🚀 Deployed to staging by https://github.com/luacmartins in version: 9.5.47-0 🚀
|
|
🚀 Deployed to staging by https://github.com/luacmartins in version: 9.5.51-0 🚀
|
|
🚀 Deployed to production by https://github.com/marcaaron in version: 9.5.51-1 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
Part of the
useOnyxtoOnyx.get/Onyx.multiGetmigration (Phase 1,src/pages/iou3 of 3).These IOU handlers read some values only when the user acts, but each value was a
useOnyxsubscription, so every change to its key re-rendered the screen or hook. Each handler now reads those values once with a singleawait Onyx.multiGet([...]), and the code below the read keeps its order. The Concierge chat key is in the same list.hasChangesbranch of the odometer edit, and insideif (policy)in Hours.handleRegularReportSelectionandremoveFromReportread first, then go back or dismiss. The transition callbacks stay synchronous.PayConfirmation.handleSendMoneyreadsquickActionand whether the report already has transactions, then passes both tosendMoney.submitWithDismissFirststill gets a synchronous write, so it runs before the report is revealed.useSendMoneySubmissionno longer subscribes throughuseReportTransactions.void | Promise<void>:onSendMoneyinMoneyRequestConfirmationList, the GPSnavigateToNextStepprop,removeFromReportinIOURequestEditReportCommon, and the report picker action types.useOnyx.Fixed Issues
$ #101910
PROPOSAL: N/A
Tests
Test 1: Odometer distance, create
Test 2: Odometer distance, edit
Test 3: GPS distance (iOS and Android native only)
Test 4: Time expense
Test 5: Change report while editing
Test 6: Remove from report
Test 7: Report pick while creating
Test 8: Pay someone from a chat
Test 9: Scan from the FAB quick action
Offline tests
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)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.1.2.4.5.6.7.mov
android.3.mov
android.8.9.mov
Android: mWeb Chrome
android.web.mov
iOS: Native
ios.1.2.4.5.6.mov
ios.3.mov
ios.7.8.mov
ios.9.mov
iOS: mWeb Safari
ios.web.mov
MacOS: Chrome / Safari
web.test.1-2.mov
web.test.4-7.mov
web.test.8.mov
web.test.9.mov