[No QA][INP] Defer PrevNextButtons-NextButton work off the press frame
Explanation of Change
Improves the INP of the PrevNextButtons-NextButton interaction by taking two costs off the press frame at all three call sites that feed this Sentry label:
1. Transaction-thread carousel (MoneyRequestReportTransactionsNavigation) — the main contributor. Previously, onNext/onPrevious ran the optimistic-thread prep (markReportIDAsExpense, setOptimisticTransactionThread, createTransactionThreadReport → openReport) synchronously on the press frame, and the existing requestAnimationFrame around Navigation.setParams fired before the next paint, so both the prep long task and the urgent destination re-render still landed inside the interaction's measurement window. Now:
- The prep is deferred to the frame after the press, so the button paints its pressed state immediately.
Navigation.setParamsruns one frame later (preserving the documented Onyx-flush ordering guard) wrapped instartTransition, so React paints first and commits the heavy destination tree (header, expense details, report-actions list) as a non-urgent transition.- The snapshot-descriptor fast paths get the same treatment.
2. Search-report carousel (MoneyRequestReportNavigation) — the report swap in goToReportId is now committed inside startTransition, and the pagination search() call (which builds optimistic snapshot data synchronously) is deferred off the press frame.
3. IOU confirmation transaction switcher (IOURequestStepConfirmation) — setCurrentTransactionID is wrapped in startTransition so the whole confirmation list re-render no longer blocks the interaction's paint.
No behavior changes: the same work runs in the same order, only its scheduling relative to the interaction's paint changes.
Metrics improvement
Interaction: PrevNextButtons-NextButton (data-sentry-label).
Captured on a production (staging) web build with the React Profiler — 11 samples before and 11 after, cold forward navigation through a 12-expense report (the Next button):
| Average total duration | |
|---|---|
| Before (main) | 36.50 ms |
| After (this PR) | 5.32 ms |
| Diff | -31.18 ms (-85.4%) |
At the commit level, the interaction drops from ~7 commits to 1 per navigation. In the baseline the heaviest commits re-render the full destination tree (~1,700 fibers each); after the change only ~174 fibers commit inside the interaction window.
The optimistic-thread prep and the destination re-render are moved off the press frame (requestAnimationFrame + startTransition), so the heavy destination commit no longer lands inside the interaction's paint window. Navigation still completes a frame later with the current expense kept on screen, so there is no visual regression, and First Paint on first open is unaffected since only the navigation work is deferred.
Fixed Issues
$ https://github.com/Expensify/App/issues/94721 PROPOSAL: https://github.com/Expensify/App/issues/94721#issuecomment-4811826025
Tests
Transaction-thread carousel:
- Create a workspace and submit 3+ expenses to the same report.
- Open the expense report and click one expense to open its transaction thread in the RHP.
- Click the Next (>) arrow in the RHP header — verify the button shows pressed feedback immediately and the next expense's details load correctly (header, amount, description, report actions).
- Keep clicking Next through all siblings, then Previous (<) back — verify every sibling renders correctly and no thread is skipped or duplicated.
- Repeat from Home > "Recently added" expense (snapshot-backed flow) — verify next/previous still resolve and open the correct sibling threads.
Search-report carousel: 6. Go to Reports > Expense reports (with more than one report), open a report. 7. Use the next/previous arrows in the header — verify navigation between reports works and the x of y counter stays correct. 8. With more results than one page, navigate near the end of the loaded list — verify the next page is fetched and navigation continues.
IOU confirmation: 9. Start a scan expense and upload multiple receipts to reach the multi-transaction confirmation step. 10. Use the next/previous arrows — verify the displayed transaction swaps correctly (receipt, amount, fields).
- [x] Verify that no errors appear in the JS console
Offline tests
- Go offline.
- Open an expense report with 3+ expenses, open one expense's thread, and click Next through siblings whose threads don't exist yet — verify the optimistic transaction thread is created and displayed correctly.
- Verify next/previous navigation still works across all three flows above while offline.
QA Steps
[No QA] — performance-only change with no user-facing behavior change. The interaction produces the same result in the same order; only the scheduling relative to paint changes, verified by the before/after React Profiler metrics above and the Tests section.
- [x] Verify that no errors appear in the JS console
PR Author Checklist
- [x] I linked the correct issue in the
### Fixed Issuessection above - [x] I wrote clear testing steps that cover the changes made in this PR
- [x] I added steps for local testing in the
Testssection - [x] I added steps for the expected offline behavior in the
Offline stepssection - [x] I added steps for Staging and/or Production testing in the
QA stepssection - [x] I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
- [x] I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
- [x] I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
- [x] I added steps for local testing in the
- [x] I included screenshots or videos for tests on all platforms
- [x] I ran the tests on all platforms & verified they passed on:
- [x] Android: Native
- [x] Android: mWeb Chrome
- [x] iOS: Native
- [x] iOS: mWeb Safari
- [x] MacOS: Chrome / Safari
- [x] I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
- [x] I followed proper code patterns (see Reviewing the code)
- [x] I verified that comments were added to code that is not self explanatory
- [x] I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
- [x] I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
- [x] If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
- [x] I followed the guidelines as stated in the Review Guidelines
- [x] I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like
Avatar, I verified the components usingAvatarare working as expected) - [x] If a new CSS style is added I verified that:
- [x] A similar style doesn't already exist
- [x] The style can't be created with an existing StyleUtils function (i.e.
StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
- [x] If new assets were added or existing ones were modified, I verified that:
- [x] The assets are optimized and compressed (for SVG files, run
npm run compress-svg) - [x] The assets load correctly across all supported platforms.
- [x] The assets are optimized and compressed (for SVG files, run
- [x] If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
- [x] If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like
Avataris modified, I verified thatAvataris working as expected in all cases) - [x] If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
- [x] If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
- [x] If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
- [x] I verified that all the inputs inside a form are aligned with each other.
- [x] I added
Designlabel and/or tagged@Expensify/designso the design team can review the changes.
- [x] I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
- [x] If the
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
https://github.com/user-attachments/assets/f238fbca-0d88-462b-863f-a82c564fb5ff
Android: mWeb Chrome
https://github.com/user-attachments/assets/515847f3-f1b5-46ae-a972-54f6d6897a8d
iOS: Native
https://github.com/user-attachments/assets/7f7f2595-6678-4fe9-a6a8-84c0a3434e18
iOS: mWeb Safari
https://github.com/user-attachments/assets/2e863398-9478-45b9-853b-fde55d870cad
MacOS: Chrome / Safari
https://github.com/user-attachments/assets/e7e1851f-b643-4432-be0c-f6329be2a913
https://github.com/user-attachments/assets/dce02779-51eb-4ab1-b644-3f13a9ed8118
Codecov Report
❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
| Files with missing lines | Coverage Δ | |
|---|---|---|
| ...es/iou/request/step/IOURequestStepConfirmation.tsx | 64.34% <100.00%> (+1.95%) |
:arrow_up: |
| ...RequestReportView/MoneyRequestReportNavigation.tsx | 6.25% <0.00%> (-0.07%) |
:arrow_down: |
| ...tView/MoneyRequestReportTransactionsNavigation.tsx | 1.08% <0.00%> (ø) |
|
| ... and 196 files with indirect coverage changes |
@DylanDylann 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]
Also please complete the author checklist
@codex review
Codex Review: Didn't find any major issues. :+1:
Reviewed commit: f55f015142
ℹ️ 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".
@dilshodmackbook-sketch Please also include the metrics improvement in the PR description
Added a Metrics improvement section to the PR description with the before/after React Profiler numbers (36.50 ms → 5.32 ms average, -85.4%) and the comparator screenshots.
I think it's safe to mark this PR as NoQA
PR doesn’t need product input as a performance PR. Unassigning and unsubscribing myself.
Reviewer Checklist
- [x] I have verified the author checklist is complete (all boxes are checked off).
- [x] I verified the correct issue is linked in the
### Fixed Issuessection above - [x] I verified testing steps are clear and they cover the changes made in this PR
- [x] I verified the steps for local testing are in the
Testssection - [x] I verified the steps for Staging and/or Production testing are in the
QA stepssection - [x] I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
- [x] I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
- [x] I verified the steps for local testing are in the
- [x] I checked that screenshots or videos are included for tests on all platforms
- [x] I included screenshots or videos for tests on all platforms
- [x] I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
- [x] I verified tests pass on all platforms & I tested again on:
- [x] Android: HybridApp
- [x] Android: mWeb Chrome
- [x] iOS: HybridApp
- [x] iOS: mWeb Safari
- [x] MacOS: Chrome / Safari
- [x] If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
- [x] I verified proper code patterns were followed (see Reviewing the code)
- [x] I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e.
toggleReportand notonIconClick). - [x] I verified that comments were added to code that is not self explanatory
- [x] I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
- [x] I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
- [x] I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e.
- [x] If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
- [x] I verified that this PR follows the guidelines as stated in the Review Guidelines
- [x] I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like
Avatar, I verified the components usingAvatarhave been tested & I retested again) - [x] If a new component is created I verified that:
- [x] A similar component doesn't exist in the codebase
- [x] All props are defined accurately and each prop has a
/** comment above it */ - [x] The file is named correctly
- [x] The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
- [x] The only data being stored in the state is data necessary for rendering and nothing else
- [x] For Class Components, any internal methods passed to components event handlers are bound to
thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor) - [x] Any internal methods bound to
thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick) - [x] All JSX used for rendering exists in the render method
- [x] The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
- [x] If any new file was added I verified that:
- [x] The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
- [x] If a new CSS style is added I verified that:
- [x] A similar style doesn't already exist
- [x] The style can't be created with an existing StyleUtils function (i.e.
StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
- [x] If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
- [x] If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like
Avataris modified, I verified thatAvataris working as expected in all cases) - [x] If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
- [x] If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
- [x] If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
- [x] I verified that all the inputs inside a form are aligned with each other.
- [x] I added
Designlabel and/or tagged@Expensify/designso the design team can review the changes.
- [x] For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
- [x] If the
mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps. - [x] I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.
Screenshots/Videos
Before
https://github.com/user-attachments/assets/5a9ddeeb-5d94-4f46-8e7d-40d1907e0dea
After
https://github.com/user-attachments/assets/0196837e-5237-4a24-8e5d-0dceeb898129
@rlinoz this is ready for your review — C+ approved and all checks are green. Thanks!
🚧 rlinoz has triggered a test Expensify/App build. You can view the workflow run here.
:hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.
:test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! :test_tube::test_tube: Built from App PR Expensify/App#95737.
| Android :robot: | iOS :apple: |
|---|---|
| https://ad-hoc-expensify-cash.s3.us-east-1.amazonaws.com/rock-artifacts/ad-hoc/rock-android-Adhoc-f1961bae741-a91d37b-d1037fdea11b950ecb45d665228520fb31485efd/index.html | https://ad-hoc-expensify-cash.s3.us-east-1.amazonaws.com/rock-artifacts/ad-hoc/rock-ios-device-AdHoc-f1961ba-a91d37b-9fbe00e040aa4584f6afdd5aa486be085aed8183/index.html |
| Web :spider_web: |
|---|
| https://95737.pr-testing.expensify.com |
:eyes: View the workflow run that generated this build :eyes:
🚀 Deployed to staging by https://github.com/rlinoz in version: 9.4.34-0 🚀
| platform | result |
|---|---|
| 🕸 web 🕸 | success ✅ |
| 🤖 android 🤖 | success ✅ |
| 🍎 iOS 🍎 | success ✅ |
🤖 Help site review — no changes required
I reviewed the changes in this PR against the help site articles under docs/articles, and no documentation updates are needed. I did not create a draft PR.
Why: This is a performance-only change (INP optimization for the PrevNextButtons-NextButton interaction). The four changed files only alter when existing work runs relative to the interaction's paint — deferring the optimistic-thread prep and destination re-render off the press frame via requestAnimationFrame and startTransition:
src/components/MoneyRequestReportView/MoneyRequestReportNavigation.tsxsrc/components/MoneyRequestReportView/MoneyRequestReportTransactionsNavigation.tsxsrc/pages/iou/request/step/IOURequestStepConfirmation.tsxtests/ui/components/IOURequestStepConfirmationPageTest.tsx
As the PR description states, there are no behavior changes — the same work runs in the same order — and it is tagged [No QA]. Nothing here introduces or renames a feature, tab, setting, label, or button, and the help site documents user-facing product behavior, not internal render scheduling. There is nothing for a help article to reflect.
Note: browser-based verification was unavailable in this run, so this assessment is based on static review of the diff and PR description. Given the change is purely internal scheduling with no UI or copy changes, that is sufficient to conclude no docs work is required.
🚀 Deployed to production by https://github.com/roryabraham in version: 9.4.34-14 🚀
| platform | result |
|---|---|
| 🕸 web 🕸 | success ✅ |
| 🤖 android 🤖 | failure ❌ |
| 🍎 iOS 🍎 | failure ❌ |