Skip to content

refactor: read src/pages/iou (2/3) Onyx data in event handlers with Onyx.get - #106705

Merged
mountiny merged 16 commits into
Expensify:mainfrom
callstack-internal:feat/onyx-get-p1-3-iou-2
Nov 21, 2026
Merged

mountiny merged 16 commits into
Expensify:mainfrom
callstack-internal:feat/onyx-get-p1-3-iou-2

Conversation

@LukasMod

@LukasMod LukasMod commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Part of the useOnyx to Onyx.get / Onyx.multiGet migration (Phase 1, src/pages/iou 2 of 3).

These 8 IOU files subscribed with useOnyx to 43 values that only an event handler reads (a row select, a form submit or a button press). Each subscription re-rendered the page when its key changed, though nothing on screen used the value. This PR deletes them. Each handler path now reads its values once, with Onyx.get or one Onyx.multiGet and a literal key list. Policy categories and tags are read the same way, with keys built inside the handler from the current policy or report. Values that had a selector (introSelected, draft transaction IDs, onboarding) get the same selector applied after the read.

What changes in each handler:

  • The handler is async and reads after any synchronous guard or early return. When only one branch needs a value, the read is in that branch, so the other paths stay synchronous. That covers the start-page check on the destination step, the edit, split-edit and create paths of manual distance (each reads only its own keys), the edit branch of merchant, tax amount and distance rate, and the bulk move after an upgrade. On the distance rate step, RULE is read in the tax branch and again with the other keys in the edit branch.
  • Async handlers are passed straight to their props, and the receiving types are widened to void | Promise<void>: Form onSubmit, SelectionList onSelectRow, AddressSearch onPress, the amount form, the destination and upgrade components, and the dismissKeyboardAndExecute callback.
  • On the upgrade step the Concierge chat is read in the same multiGet, so conciergeReportID stays on useOnyx to build its key.
  • The edit report list keeps its two pagination flags on useOnyx, because FlashList also calls onEndReached from a post-render effect (ONYX-1 section C).
  • The offline waypoint save is awaited before going back, so the waypoint is saved before the screen closes.
  • No key is read after a write to it in the same tick.

Bindings that remain on useOnyx are used in render or read a key that Onyx.get does not allow (policy_, report_, reportActions_ and transactionViolations_).

IOURequestEditReportCommonTest and IOURequestStepReportTest wait for batched updates after selecting a report, because the selection now runs after the read. Three test mocks that forward onSelectRow or onSubmit into a native onPress use a block arrow, so the mocked onPress stays void.

Fixed Issues

$ #101910
PROPOSAL: N/A

Tests

Test 1: Per diem destination

  1. On a workspace with per diem rates, start a per diem expense from the global create button.
  2. Pick a destination.
  3. Verify you move on to the time step.

Test 2: Manual distance

  1. Start a manual distance expense, enter a distance and tap Next. Verify confirmation shows the distance and amount.
  2. Open an existing manual distance expense, change the distance and save. Verify the distance and amount update.
  3. Open a split of a distance expense, change its distance and save. Verify the split shows the new distance.

Test 3: Distance rate and merchant

  1. Open an existing distance expense on a workspace with taxes and several rates.
  2. Tap Rate, pick another rate and tap Save. Verify the rate and amount update and the RHP goes back.
  3. Open a different manual expense, tap Merchant, change it and save. Verify the merchant updates and the RHP goes back.

Test 4: Upgrade from a track expense

  1. In a self DM track expense with no paid workspace, tap Categorize it and upgrade.
  2. Fill the workspace form and confirm. Verify the workspace is created.
  3. Tap Got it. Verify you reach the category step.

Test 5: Bulk move through the upgrade

  1. On Reports > Expenses, select several unreported expenses and choose Move expenses.
  2. Create a report so the upgrade appears, then upgrade and tap Got it.
  3. Verify all selected expenses move to a new report on the new workspace.

Test 6: Waypoint

  1. Start a map distance expense and tap a stop.
  2. Pick a suggested address. Verify the stop is set and the map goes back.

Test 7: Edit report

  1. Open an expense on a report and tap Report. Pick a different report. Verify the expense moves to it.
  2. On an account with many open reports, scroll to the end of the list. Verify more reports load.
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline.
  2. Repeat Tests 2 (step 2), 3 and 7 (step 1). Verify each change applies optimistically and shows the pending (greyed out) state.
  3. Go back online. Verify the changes sync without errors.

QA Steps

Same as tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • 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)
    • 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).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • 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)
  • I verified any copy / text that was added to the app 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)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • 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 using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • 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.
  • 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 Avatar is modified, I verified that Avatar is working as expected in all cases)
  • 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.
  • 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.
  • 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:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android.mov
Android: mWeb Chrome
android.web.4.mov
android.web.5.mov
android.web.6.mov
android.web.mov
iOS: Native
ios.1-3.mov
ios.6-7.mov
iOS: mWeb Safari
ios.web.mov
MacOS: Chrome / Safari
web.1-3.mov
web.4-5.mov
web.6.mov
web.7.mov

@LukasMod LukasMod changed the title [NoQA] refactor: read src/pages/iou (2/3) Onyx data in event handlers with Onyx.get refactor: read src/pages/iou (2/3) Onyx data in event handlers with Onyx.get Nov 12, 2026
@melvin-bot

melvin-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

@LukasMod
LukasMod force-pushed the feat/onyx-get-p1-3-iou-2 branch from 20d5cc5 to b0d5073 Compare November 16, 2026 14:40
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

@LukasMod

Copy link
Copy Markdown
Contributor Author

@MelvinBot review

@MelvinBot

Copy link
Copy Markdown
Contributor

Found one issue:

[P2] Keep pagination flags subscribed — IOURequestEditReportCommon.tsx:510

FlashList can invoke onEndReached from its commit effect, so this callback reaches Onyx.multiGet outside a user event. That violates ONYX-1’s cross-file effect restriction. Retain useOnyx for hasMoreOutstandingReports and isLoadingOutstandingReports.

No other actionable correctness findings. Static review only; web testing was not run.


view run

@LukasMod
LukasMod force-pushed the feat/onyx-get-p1-3-iou-2 branch from 1ae6658 to 0ccedd7 Compare November 17, 2026 13:14
@LukasMod

Copy link
Copy Markdown
Contributor Author

@MelvinBot review

Regarding onEndReached, I think it’s safe to read here. Nothing re-runs when these two flags change, because FlashList reads the latest onEndReached prop on each call and only re-checks bounds on its own renders and scrolls

@MelvinBot

Copy link
Copy Markdown
Contributor

Your reasoning is sound: FlashList reads the current callback when checking bounds, and the handler reads both flags afresh. Their changes alone don’t trigger another check. I found no stale-read or feedback-loop regression, so I withdraw the P2 correctness finding.

The remaining distinction is policy: ONYX-1 C1 still explicitly prohibits effect-reachable reads. This warrants a maintainer-approved exception or rule clarification—not a claim that restoring subscriptions fixes a demonstrated bug.

No additional actionable correctness findings in the updated diff. Static review only.


view run

@LukasMod

Copy link
Copy Markdown
Contributor Author

@MelvinBot test

@MelvinBot

MelvinBot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Web test steps verification results: ⚠️ partial

Verified manual distance confirmation, existing merchant update, and category-upgrade navigation on dev NewDot web. The tester reached its execution limit; remaining checks were unverified or lacked prerequisites.

Category step opened after workspace upgrade acknowledgment

Step Status
1.1 — Start per diem expenseWorkspace per diem rates were not configured.
⚠️
1.2 — Destination advances to time stepPer diem prerequisite unavailable.
⚠️
1.3 — Edit existing per diem destinationNo existing per diem expense available.
⚠️
2.1 — Manual distance confirmationEntered 10 miles; Next opened confirmation showing 10.00 miles and $7.60.
Manual distance confirmation showing 10 miles and $7.60
✅
2.2 — Edit existing manual distanceChanged input from 10 to 20, but execution stopped before Save; persistence and amount update remain unverified.
⚠️
2.3 — Edit split distanceSplit distance draft was not prepared or tested.
⚠️
3.1 — Change distance rateMultiple workspace distance rates were not configured.
⚠️
4.1 — Edit existing merchantSaved merchant change; editor closed and expense details plus activity history showed the update.
Expense details showing the saved merchant update
✅
4.2 — Merchant on new expense confirmationCreated expense retained the merchant, but this flow created it directly without the requested confirmation screen.
⚠️
5.1 — Edit tax amountTax-enabled workspace expense was not prepared.
⚠️
6.1 — Category workspace upgradeCategory opened the upgrade flow. Workspace creation succeeded; Got it, thanks opened selectable categories. Entry action was labeled Category rather than Categorize it.
Category step opened after workspace upgrade acknowledgment
✅
6.2 — Distance-rate upgradeNot exercised; account already had the workspace created during 6.1.
⚠️
6.3 — Bulk move after upgradeMultiple unreported expenses and independent upgrade prerequisites were not prepared.
⚠️
7.1 — Suggested waypoint addressMap screen opened, but suggested-address selection was not tested.
⚠️
7.2 — Recent destinationNo recent destination fixture was prepared.
⚠️
8.1 — Move expense between reportsMove to report initially opened Upgrade; subsequent report selection and movement were not tested.
⚠️
8.2 — Report paginationMany-open-reports prerequisite was unavailable.
⚠️
8.3 — Restricted billing action (optional)Ended billing grace with amount owed prerequisite was unavailable.
⚠️
Console — No JavaScript errorsConsole was not inspected; absence of errors is unverified.
⚠️
Offline 1 — Go offlineOffline mode was not enabled.
⚠️
Offline 2 — Optimistic edits and pending stateOffline distance, rate, merchant, tax, and report edits were not tested.
⚠️
Offline 3 — Save typed waypointNot tested.
⚠️
Offline 4 — Report pagination makes no requestNot tested.
⚠️
Offline 5 — Reconnect and synchronizeNot tested.
⚠️

view run · view recording

@LukasMod
LukasMod force-pushed the feat/onyx-get-p1-3-iou-2 branch from 0ccedd7 to 641d1ca Compare November 18, 2026 08:32
@LukasMod
LukasMod marked this pull request as ready for review November 18, 2026 14:04
@LukasMod
LukasMod requested review from a team as code owners November 18, 2026 14:04
@github-actions

Copy link
Copy Markdown
Contributor

This PR adds a new Onyx.get or Onyx.multiGet call, so I've requested a review from the Onyx performance reviewers (@tgolen, @mountiny, @chuckdries, @luacmartins). A review from any one of them is enough. Please check the call against the Onyx.get() rules in ONYX-DATA-MANAGEMENT and ONYX-1.

@LukasMod

Copy link
Copy Markdown
Contributor Author

@aimane-chnaif
Thanks! I forgot to push commit with those functions renames 🫣 sorry. All fixes pushed, onEndReached change reverted

@aimane-chnaif

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • 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)
    • 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)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • 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.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • 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
  • I verified any copy / text that was added to the app 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)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • 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 using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • 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
  • 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.
  • 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 Avatar is modified, I verified that Avatar is working as expected in all cases)
  • 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.
  • 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.
  • 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:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
test1.mov
test2.mov

@garrettmknight
garrettmknight removed their request for review November 18, 2026 20:48
luacmartins
luacmartins previously approved these changes Nov 19, 2026

@mountiny mountiny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like others already approved so we can move it ahead

@mountiny
mountiny merged commit ab89c33 into Expensify:main Nov 21, 2026
39 of 40 checks passed
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

Copy link
Copy Markdown
Contributor

🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

Copy link
Copy Markdown
Contributor

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.5.53-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

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.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/arosiclair in version: 9.5.53-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

1 similar comment
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/arosiclair in version: 9.5.53-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants