Skip to content

Fix device back from Submit to my employer confirmation landing on the workspace chat - #97512

Draft
abzokhattab wants to merge 1 commit into
Expensify:mainfrom
abzokhattab:fix/97437-submit-employer-device-back
Draft

Fix device back from Submit to my employer confirmation landing on the workspace chat#97512
abzokhattab wants to merge 1 commit into
Expensify:mainfrom
abzokhattab:fix/97437-submit-employer-device-back

Conversation

@abzokhattab

Copy link
Copy Markdown
Contributor

Explanation of Change

On narrow layout, the submit confirmation RHP pre-mounts its destination report under itself (usePreMountDestination) so post-submit dismissal reveals an already-rendered screen. A report route resolves to the tab navigator, so the pre-insert takes the tab-switch path: it rewrites the focused tab's inner state in place (self DM → workspace chat) and saves the original route aside. When the flow is cancelled while the RHP is still open, the router action restores that saved route fully. But when the device back button pops the RHP before the cleanup runs, removePreInsertedFullscreenIfNeeded only re-focused the original tab by name — a no-op when the pre-insert stayed on the same tab — so the saved state was dropped and the pre-inserted workspace chat stayed on screen instead of the self DM.

The fix: in the RHP-already-dismissed cleanup path, when the focused tab is unchanged, reset the tab navigator to the saved original state instead of the no-op jumpTo. The cross-tab path (jumpTo) and the RHP-still-open path are unchanged. In the "Submit to my employer" auto-skip flow this became reachable after #97057 bound the draft to the destination workspace chat, which made that report the pre-mount destination.

Fixed Issues

$ #97437
PROPOSAL:

Tests

With the submit2026 beta enabled, on an account with a self DM and exactly one paid workspace, on Android (or any narrow layout):

  1. Open the self DM and create a manual expense.
  2. On the expense whisper, tap Submit it to my employer — the confirmation page opens directly (no destination picker).
  3. Press the device back button.
  4. Verify you land back on the self DM, not the workspace chat.
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests while offline — the flow is navigation-only, so behavior is identical.

QA Steps

  1. On an account with the submit2026 beta, a self DM and exactly one paid workspace, create a manual expense in the self DM on Android.
  2. Tap Submit it to my employer, then press the device back button on the confirmation page.
  3. Verify you return to the self DM instead of the workspace chat.
  • 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 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.
  • 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: mWeb Safari
MacOS: Chrome / Safari

…inserted report on screen

When a report is pre-inserted under the RHP within the same tab, the
RHP-already-dismissed cleanup only jumped to the original tab name, which is a
no-op that drops the saved tab state. Reset the tab navigator to the saved
original state instead so the report the flow started from is restored.
@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/libs/Navigation/Navigation.ts 57.42% <85.71%> (+9.69%) ⬆️
... and 20 files with indirect coverage changes

@abzokhattab

Copy link
Copy Markdown
Contributor Author

Some provenance worth having on record: the broken restore path this PR fixes is a pre-existing latent defect, and it was actually fixed once before. Commit aee58a1 (part of #91062, May 27) identified the same mechanism in the workspace-creation flow — "jumpTo works for the cross-tab case but is a no-op when the pre-insert happened in the same tab" — and replaced the jumpTo with a state reset. #91062 was then reverted wholesale (#93017) because of two deploy blockers in its workspace-creation changes (#93000, #93003), and the re-implementation (#93915) never restored the cleanup fix, so main has carried the no-op restore since June 9. #97057 simply created the first commonly-exercised path onto it: the auto-skip "Submit to my employer" flow now pre-inserts a report over a report on the same tab.

Two notes for review confidence:

  • This fix is narrower than the May one: it only resets when the focused tab is unchanged; the cross-tab jumpTo and the RHP-still-open router restore are byte-identical to current main.
  • It cannot resurrect the Fix workspaces list flash on narrow when creating a workspace #91062 blockers: the workspace-creation flow no longer uses the pre-insert machinery at all (only the IOU step pages call usePreMountDestination today).

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.

1 participant