Skip to content

Restructure IOURequestStepConfirmation ahead of the per-path split - #103720

Merged
mountiny merged 12 commits into
Expensify:mainfrom
callstack-internal:VickyStash/refactor/99449-confirmation-split-prep
Oct 16, 2026
Merged

mountiny merged 12 commits into
Expensify:mainfrom
callstack-internal:VickyStash/refactor/99449-confirmation-split-prep

Conversation

@VickyStash

@VickyStash VickyStash commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

This PR prepares IOURequestStepConfirmation for the split per submission path. It doesn't change behavior.

  • The page moves to IOURequestStepConfirmation/index.tsx, and its props types move to types.ts.
  • Three parts of the page move into their own hooks:
    • useConfirmationTransactionPager tracks which transaction is shown and handles prev/next and remove.
    • useParticipantPickerState owns the in-place "To" picker and what picking a participant writes to the transaction.
    • useSubmitDestinationPreMount resolves the report the expense lands on and pre-mounts it.
  • useSubmitLock holds isConfirmed and formHasBeenSubmitted. They lived inside useExpenseSubmission, but the page reads them as well, so the page now creates the lock and passes it in.
  • useExpenseSubmission now uses two small helpers that the per-path variants will share in the next PR:
    • guardSubmission runs the checks before a submit: span tag, distance block, then the lock.
    • useSubmissionOnboardingIntent returns the onboarding flags that decide where an expense lands.

The next PR will fork the page into one variant per submission path, so each confirmation mounts only the submission hook it uses.

Fixed Issues

$ #99449
PROPOSAL: N/A

Tests

  • Verify that no errors appear in the JS console
  1. Create a manual expense from FAB to a workspace. Verify it is created and you land on the right report.
  2. During scan flow, select multiple receipts. On the confirmation page, use the prev/next arrows in the header, remove one receipt, and submit. Verify the right receipts are submitted.
  3. Start an expense from FAB. Update the participant a couple of times and submit the creation. See the expense created for the correct recipient.
  4. Submit a distance expense to a workspace, and a track expense to the self DM. Verify both land on the right report.
  5. Pay someone. Verify it works.
  6. Send an invoice to someone. Verify it works.
  7. Create a manual expense and double-tap the confirm button quickly. Verify that only one expense is created.

Offline tests

Same, as in Tests section

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • Verify that no errors appear in the JS console

Same, as in Tests section

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 followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • 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.
    • 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)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • 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 a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • 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

MacOS: Chrome / Safari

FAB creation + change participants + double-click:

FAB+double-click.mp4

Pay:

pay1.mp4

Invoice:

invoice1.mp4

Multi-scan:

multi-scan.mp4

Distance:

distance1.mp4

@codecov

codecov Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

@VickyStash

Copy link
Copy Markdown
Contributor Author

@MelvinBot review

@MelvinBot

Copy link
Copy Markdown
Contributor

Review

The refactor looks safe to merge once the description is filled in. I compared every moved block with the original and found no behavior change. Two small suggestions:

  1. The test stub copies the lock logic instead of using it. useExpenseSubmission.test.ts:203 buildSubmitLock re-implements lockSubmission/unlockSubmission. If useSubmitLock regresses, these tests still pass. Use the real hook instead, for example renderHook(() => useSubmitLock()).
  2. The page still computes the onboarding intent itself. IOURequestStepConfirmation/index.tsx:218-219 repeats the isLookingAroundUser logic that is now in useSubmissionOnboardingIntent. Call the hook here too so both use one source.

Also, the PR body still needs the Explanation of Change, Tests, and QA sections.

What I checked
  • Moved logic: I compared the participant picker, destination pre-mount, transaction pager, and submit lock with the original code. Only memoization wrappers changed.
  • useMemo/useCallback removal: This follows the App rule for React Compiler code. The React Compiler Compliance check passes, so the new hooks compile and the inline existingP2PChatSelector stays stable. Using getEmptyArray for defaultParticipants gives a more stable reference than the old [].
  • Hook order: The pre-mount effects now run before useExpenseSubmission. The only effect inside it is the ref sync in useSubmissionViolations, so the order doesn't matter. The pre-mount cleanup still runs before the telemetry-cancel cleanup.
  • Lock sharing: formHasBeenSubmitted now comes from useSubmitLock, which runs before both consumers. So shouldPreservePreInsertedRouteOnUnmount and the unmount cleanup read the same ref that guardSubmission sets.
  • guardSubmission: It keeps the original order: span attribute, distance block, lock, then submit. The default arguments are unchanged.
  • Callers: useExpenseSubmission no longer returns isConfirmed, setIsConfirmed, or formHasBeenSubmitted. The only caller is the page, and it now reads them from submitLock.

@VickyStash
VickyStash marked this pull request as ready for review October 12, 2026 14:50
@VickyStash
VickyStash requested review from a team as code owners October 12, 2026 14:50
@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and situchan and removed request for a team October 12, 2026 14:50
@melvin-bot

melvin-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown

@situchan 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]

@melvin-bot
melvin-bot Bot removed the request for review from a team October 12, 2026 14:50
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T14:44:39.205576Z 2b7fa5a Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@mountiny
mountiny self-requested a review October 12, 2026 14:58
@mountiny

Copy link
Copy Markdown
Contributor

@situchan seems like this is ready for your review.

@situchan

situchan commented Oct 12, 2026 •

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
test.mov

@VickyStash

Copy link
Copy Markdown
Contributor Author

Hey @situchan, how is it going?

@situchan

Copy link
Copy Markdown
Contributor

Almost done

@JmillsExpensify JmillsExpensify 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.

No product review required.

@situchan

Copy link
Copy Markdown
Contributor

No issues found. Let's also get 2nd 👁️ from bots

@situchan

Copy link
Copy Markdown
Contributor

@codex review

@situchan

Copy link
Copy Markdown
Contributor

@MelvinBot review

Comment on lines +168 to +169
// eslint-disable-next-line react-hooks/exhaustive-deps
if (hasSubmitIntent || formHasBeenSubmitted.current) {

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.

Likely dead eslint-disable

exhaustive-deps only flags .current in cleanup for a local useRef. formHasBeenSubmitted is now a param.

Fix: remove it, or add a justification if lint still needs it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It triggered lint error, so I just added a comment in 19e1f5b

@MelvinBot

Copy link
Copy Markdown
Contributor

Review

No blocking issues. I reviewed the two commits added since my last review and found no behavior change.

Two PR body nits:

  1. QA Steps still has the template line // TODO: These must be filled out, or the issue title must include "[No QA]." Remove it.
  2. Tests step 6 says "ivoice." It should say "invoice."

CI is green except the checklist and approval checks, which wait on reviewers.

@MelvinBot

Copy link
Copy Markdown
Contributor

Regression check

I found no regressions. I compared every moved block with the base page at 37e2b8b, and each one does the same thing in the same order.

I found one low-risk difference to be aware of:

  • The pre-mount route no longer has a useMemo. useSubmitDestinationPreMount.ts:122-134 calls getSubmitExpensePreMountDestinationRoute directly. The base wrapped that call in useMemo (IOURequestStepConfirmation.tsx:747). The builder reads live Navigation state, so it now relies on React Compiler to avoid re-reading that state on unrelated renders. The compliance check passes, and usePreMountDestination compares the route by value. I couldn't build a scenario where the route changes, so no action is needed.
What I compared
  • Participant picker (useParticipantPickerState): hook inputs, default participants, auto-open and close, the focus listener, what handleParticipantsAdded writes (self DM, P2P, and workspace rates, plus the category and tag reset), the auto-assign effect and its deps, and the picker props. All match. getEmptyArray keeps defaultParticipants stable, so the auto-assign effect doesn't loop.
  • Transaction pager (useConfirmationTransactionPager): the index lookup, prev/next, remove, and the OPTIMISTIC_TRANSACTION_ID replace path. All match. The pager has no effects.
  • Destination pre-mount (useSubmitDestinationPreMount): the destination choice for self DM, per diem, backToReport, and P2P, plus the draft-copy effect, the row-cleanup effect, and shouldPreservePreInsertedRouteOnUnmount. All match.
  • Submission: guardSubmission keeps the base order: span tag, distance block (returns before the lock), lock, then submit. unlockSubmission has the same body as the old releaseSubmitLock, and split is still the only path that uses it. Send money still gets the raw setIsConfirmed. The confirm button, handleSendMoney, the pre-mount hook, and useExpenseSubmission all share one useSubmitLock instance.
  • Onboarding intent: the hook reads the same Onyx key and the same useNetwork().isOffline.
  • Hook order: the pre-mount effects now run before useExpenseSubmission. Its only effect is a ref sync in useSubmissionViolations with no cleanup. On unmount, the pre-mount cleanups still run before cancelTracking.
  • Callers: only the page calls useExpenseSubmission. The old import path resolves to the new folder's index.tsx, and both exports are still there.

I compared the code only. I didn't run the app.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 2b7fa5a08f

ℹ️ 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".

@mountiny

Copy link
Copy Markdown
Contributor

@VickyStash can you please check the comments from @situchan ? thanks

@VickyStash

Copy link
Copy Markdown
Contributor Author

@mountiny Done!

@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.

🚀

@mountiny
mountiny merged commit 1708370 into Expensify:main Oct 16, 2026
38 of 41 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

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

@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.

@OSBotify

Copy link
Copy Markdown
Contributor

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

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update is needed. This PR only restructures IOURequestStepConfirmation into hooks and helpers with no user-facing behavior change, so no sentence in App/docs/articles becomes incorrect.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/grgia in version: 9.5.14-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.

6 participants