Skip to content

[Performance] Reduce DEFAULT handler fallthrough for unrecognized-tab submissions#94454

Merged
mountiny merged 19 commits into
Expensify:mainfrom
software-mansion-labs:korytko/fix-default-handler-frequency
Jul 2, 2026
Merged

[Performance] Reduce DEFAULT handler fallthrough for unrecognized-tab submissions#94454
mountiny merged 19 commits into
Expensify:mainfrom
software-mansion-labs:korytko/fix-default-handler-frequency

Conversation

@JakubKorytko

@JakubKorytko JakubKorytko commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Three related submit-navigation improvements:

1. Reduce DEFAULT handler frequency for global-create flows from unrecognized tabs

Added a SEARCH_DISMISS condition in getSubmitHandler for global-create flows from Home, Settings, and Workspaces tabs. These were falling through to the slow DEFAULT path (which runs createTransaction before navigation) even though the correct behavior is identical to SEARCH_DISMISS.

2. Fix PAY navigation on wide layout (repeated QAB Pay stays on Home)

submitWithDismissFirst used getTopmostReportParams to detect "already on destination", but this finds stale report routes in the nav state even when the active tab is Home. After the first PAY navigates to the report, subsequent PAYs incorrectly think they're "already on destination" and just dismiss - landing on Home instead of the report. Fixed by gating the check behind isReportTopmostSplitNavigator() so it only considers the report visible when it's actually the active tab.

3. Honor pre-inserted routes instead of replacing them

Both submitWithDismissFirst and SubmitExpenseOrchestrator.handleReportPreInsert could call revealRouteBeforeDismissingModal even when a route was already pre-inserted under the RHP. This replaces the pre-rendered React tree, wasting the pre-insertion work and causing a visible flash. Fixed by checking getIsFullscreenPreInsertedUnderRHP() before falling back to reveal. Also added report pre-insertion for skip-confirmation PAY flows in IOURequestStepAmount and enabled report pre-insertion for PAY/SPLIT from global create in IOURequestStepConfirmation.

Sentry Evidence

Sentry shows ~5.2k default vs ~4k non-default fast_path_handler values on ManualSubmitToDestinationVisible spans in the last 24h [23.06.2026] (~56% default). The app has 5 tabs but handler selection only recognizes 2 (Search and Reports). HOME (the initial route), Settings, and Workspaces tabs are "unrecognized" and all fall through to DEFAULT even though the correct behavior is identical to SEARCH_DISMISS.

Estimated DEFAULT breakdown:

  • Non-global-create (from within report): ~30-40% of all (by design)
  • Global create, manual participant, web: ~15-20% (pre-insert disabled on wide layout)
  • Global create, manual participant, mobile from Inbox: ~5-10% (search pre-insert blocked)
  • Global create from unrecognized tabs (Home/Settings/Workspaces): ~5% (1st fix)

Fixed Issues

$ #94463
PROPOSAL: N/A

Tests

  1. Open the app on the Home tab (or Settings/Workspaces)
  2. Tap the global FAB > "Create expense", fill in the details (amount, workspace recipient), and submit
  3. Verify [Sentry][ManualSubmitToDestinationVisible] Ending span (Xms) appears in console with a sub-two-second duration and attributes showing fast_path_handler: search_dismiss or fast_path_handler: search_pre_insert (not default)
  4. Verify the expense appears correctly in Spend

  1. Repeat from the Spend tab itself
  2. Verify the existing SEARCH_DISMISS behavior is unchanged (modal dismisses, stays on Spend)

  1. Open a DM chat and use the "+" button > "Pay Someone" to send money (this sets PAY as the QAB)
  2. Go back to the Home tab and use the QAB to initiate a new "Pay Someone" flow
  3. Complete the flow and submit
  4. Verify [Sentry][ManualSubmitToDestinationVisible] Ending span (Xms) appears in console and does NOT show fast_path_handler: search_dismiss
  5. Verify the payment opens the correct report (not Spend)

Offline tests

N/A

QA Steps

Same as tests

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 any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • 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 any new file was added I verified that:
    • 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
  • 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.
  • 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: mWeb Chrome
iOS: Native
iOS.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
Web.mov

@JakubKorytko

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0a948a7299

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

Comment thread src/pages/iou/request/step/confirmation/getSubmitHandler.ts Outdated
@JakubKorytko

Copy link
Copy Markdown
Contributor Author

@codex review

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

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 Δ
...rc/pages/iou/request/step/IOURequestStepAmount.tsx 86.27% <ø> (ø)
...es/iou/request/step/IOURequestStepConfirmation.tsx 63.93% <100.00%> (+0.21%) ⬆️
.../pages/iou/request/step/IOURequestStepDistance.tsx 76.47% <ø> (ø)
...equestStepScan/components/ScanSkipConfirmation.tsx 76.69% <100.00%> (+0.22%) ⬆️
.../iou/request/step/confirmation/getSubmitHandler.ts 100.00% <100.00%> (ø)
src/hooks/useSkipConfirmationPreInsert.ts 91.66% <91.66%> (ø)
.../libs/Navigation/helpers/submitWithDismissFirst.ts 79.06% <44.44%> (-9.51%) ⬇️
...st/step/confirmation/SubmitExpenseOrchestrator.tsx 46.72% <0.00%> (-2.78%) ⬇️
... and 69 files with indirect coverage changes

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 930feca1c4

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

Comment thread src/pages/iou/request/step/confirmation/getSubmitHandler.ts Outdated
@JakubKorytko

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: a44add6bb5

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

@JakubKorytko JakubKorytko changed the title [WIP] [Performance] Reduce DEFAULT handler fallthrough for unrecognized-tab submissions [Performance] Reduce DEFAULT handler fallthrough for unrecognized-tab submissions Jun 26, 2026
@JakubKorytko

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: acf836b12d

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

Comment thread src/libs/Navigation/helpers/submitWithDismissFirst.ts
Comment thread src/pages/iou/request/step/IOURequestStepAmount.tsx Outdated
@JakubKorytko

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e90bf8b6d1

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

@JakubKorytko

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e90bf8b6d1

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

Comment thread src/pages/iou/request/step/confirmation/getSubmitHandler.ts
@JakubKorytko

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 55cfe35481

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

@JakubKorytko JakubKorytko marked this pull request as ready for review June 26, 2026 15:43
@JakubKorytko JakubKorytko requested review from a team as code owners June 26, 2026 15:43
@melvin-bot melvin-bot Bot requested a review from FitseTLT June 26, 2026 15:44
Comment thread src/pages/iou/request/step/IOURequestStepAmount.tsx Outdated
@JakubKorytko

Copy link
Copy Markdown
Contributor Author

@JakubKorytko creating a dm expense from workspace page has inconsistent behavior when it is the normal flow vs QAB.

Not sure what you mean, but if it is about the navigation then it matches prod behavior - QAB navigates to Inbox while FAB goes to Spend. Not a regression from this PR. In fact QAB has many different navigations compared to FAB.

Comment thread src/pages/iou/request/step/IOURequestStepAmount.tsx Outdated
Comment thread src/pages/iou/request/step/IOURequestStepAmount.tsx Outdated
@FitseTLT

FitseTLT commented Jun 30, 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 proper code patterns were followed (see Reviewing the code)
    • 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. toggleReport and not onIconClick).
    • 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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • 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 and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 any new file was added I verified that:
    • 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
  • 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 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.
  • 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
2026-07-01.18-26-59.mp4
Android: mWeb Chrome
2026-07-01.18-00-14.mp4
iOS: HybridApp
2026-07-01.18-41-32.mp4
iOS: mWeb Safariry>
https://github.com/user-attachments/assets/523d862a-96b3-4a0e-95d3-7cd6827b0412

MacOS: Chrome / Safari
2026-07-01.17-52-51.mp4

@FitseTLT

FitseTLT commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

I think we need some delay for useSkipConfirmationPreInsert because the pre insert is seen briefly before the create expense rhp opens. And also, it is not working for distance cases, you can try skipConfirmation case for track expense distance QAB it is slow (unlike quick pre-insert) but for scan and manual it is working.

2026-07-01.01-56-05.mp4

@JakubKorytko

Copy link
Copy Markdown
Contributor Author

^ true, fixed

Comment thread src/hooks/useSkipConfirmationPreInsert.ts
Comment thread src/hooks/useSkipConfirmationPreInsert.ts

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

LGTM

@melvin-bot melvin-bot Bot requested a review from mountiny July 1, 2026 16:03
@mountiny mountiny merged commit a64b68c into Expensify:main Jul 2, 2026
36 checks passed
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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

@OSBotify

OSBotify commented Jul 2, 2026

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

OSBotify commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.27-1 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 I reviewed the changes in this PR against Expensify's help site content under App/docs/articles.

No help site changes are required.

This PR is a set of internal navigation/performance improvements to the expense submit flow — there is no user-facing behavior change to document:

  • Reduced DEFAULT handler fallthrough — an internal handler-selection optimization (getSubmitHandler) so global-create submissions from Home/Settings/Workspaces tabs take the faster SEARCH_DISMISS path. Same end result, just faster.
  • PAY navigation fix on wide layout — corrects which report is shown after a repeated QAB "Pay someone" (opens the correct report instead of staying on Home). This restores intended behavior rather than introducing new behavior.
  • Honoring pre-inserted routes — avoids replacing a pre-rendered route (removes a visible flash). Purely a rendering/performance detail.

None of these touch documented feature names, tab names, settings labels, buttons, or user-facing workflows described on the help site, so no articles need updating and no draft PR was created.

@JakubKorytko, if you believe any user-facing behavior here should be documented, let me know and I'll open a draft help site PR.

@OSBotify

OSBotify commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/grgia in version: 9.4.27-2 🚀

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