Skip to content

Remove unsafe assertions from navigation and debug helpers - #100768

Draft
KJ21-ENG wants to merge 6 commits into
Expensify:mainfrom
KJ21-ENG:seatbelt-v2/batch1-group1-43192ddd
Draft

KJ21-ENG wants to merge 6 commits into
Expensify:mainfrom
KJ21-ENG:seatbelt-v2/batch1-group1-43192ddd

Conversation

@KJ21-ENG

@KJ21-ENG KJ21-ENG commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Remove unsafe type assertions from navigation and debug helpers with producer-derived types and guards. Links, history, workspace panels, and debug lookup retain their intended behavior; malformed nested navigation params stop at the first safe level when placing the initial sidebar marker.

Changed files (9)
  • src/libs/Navigation/helpers/getAdaptedStateFromPath.ts
  • src/libs/Navigation/helpers/getPathFromState.ts
  • src/libs/Navigation/helpers/getStateFromPath.ts
  • src/libs/Navigation/helpers/hasDifferentSplitScope.ts
  • src/libs/Navigation/helpers/linkTo/getMinimalAction.ts
  • src/libs/Navigation/helpers/linkTo/index.ts
  • src/libs/Navigation/helpers/linkTo/types.ts
  • src/libs/Navigation/helpers/replacePathInNestedState.ts
  • src/setup/addUtilsToWindow.ts

Fixed Issues

$ #94739
PROPOSAL: #94739 (comment)

Tests

Checked-in tests/navigation/getPathFromStateTests.ts and tests/navigation/getStateFromPathTests.ts passed with the focused navigation Jest checks. Focused lint, formatting, and spelling checks on the changed paths passed.

Offline tests

QA Steps

  • 1. Report/message links and history.

    • From a conversation containing links to another report and a specific message, follow each link and use browser Back.
    • Expect the correct report/message and a direct return to the starting conversation.
    • For the message link, also use Forward and Back; expect the same message target to be restored without duplicate history steps.
  • 2. Room context.

    • Open and close room details for rooms in two workspaces.
    • Expect the correct workspace label and a return to the original room each time.
  • 3. Narrow Members return.

    • In a narrow layout, open Workspaces > Search Members > a workspace's Members, then use browser Back.
    • Expect Workspaces directly, without an extra sidebar/history step.
  • 4. Concierge return.

    • Open About > Report a bug.
    • Expect Concierge.
    • Use browser Back and expect About without sending a message.
Coverage and evidence limits
  • Package status: Ready for handoff with retained findings and a disclosed console-evidence gap; audited functional minimum observed.

  • Provenance: Delivery source head 461440ac67fc362ed6dc3637b1e55c91f50e1e96 matches the verified live head. Earlier-recording reuse and other provenance limits below remain applicable; this delivery does not add fresh QA execution.

  • Interpretation: The expected outcomes above are instructions for testers. Blocked, failed, and unobserved assertions retain their original status. Console errors are documented as non-blocking findings; no clean-console result is claimed.

  • Platforms: Windows Chrome desktop and, only where labelled, narrow responsive Windows Chrome. Native Android/iOS and Safari were excluded from this package.

  • The new current-head desktop Forward supplement is fully reviewed/backed up and closes the functional history gap. Older clips use a prior head whose navigation code was audited unchanged; the two narrow clips use the current head. Console findings and the distinction between browser Back and App Back remain.

  • Recordings show actual Windows Chrome desktop and, where labelled narrow, the same Windows Chrome responsive viewport. They do not establish native Android/iOS or Safari execution. Findings are retained; these packages do not claim a clean console or all-platform success.

  • The final buffered-console read after neutralizing the tab was refused by the browser security gate. Per-transition pages were retained, but the tail interval has a gap; the original result stays incomplete-evidence for that console assertion. No clean-console claim or retry through another tool. Functional observations are established; historical broader contracts are unchanged.

  • Clips 03 and 04 are privacy derivatives of the same original continuous timelines (194.5 seconds and 69.8 seconds), with no additional cuts or speed changes. Static opaque masks hide account login aliases, including captured transitions. They also cover small same-position portions of incidental room descriptions, thumbnails, recent-search/sidebar text, workspace labels, the About logo and the Concierge greeting. Member count, display names and roles, useful route context, Report a bug, Concierge welcome content and the return remain visible; obscured text is not readable evidence. The full final timelines, first/last frames and sensitive transitions were reviewed; source evidence and original results remain privately preserved and unchanged. Output is video-only H.264 at 30 FPS; this does not establish 60 FPS capture. No new QA assertions were made.

PR Author Checklist

The cases cover links, attachment, history, workspace details, Concierge, and cached offline navigation. This change has no new user-input error flow, UI, copy, style, asset, generic component, Storybook story, or message editing. High Traffic and platform verification remain pending.

  • 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

Recordings (5)
01-report-message-links-narrow.mp4
02-room-context-desktop.mp4
03-members-return-narrow.mp4
04-concierge-return-narrow.mp4
05-marked-message-forward-desktop.mp4

Seatbelt-Operation: s08-43192ddd-4541881-sign-1
Seatbelt-Operation: recovery-20260924-100768-merge-sign-1
@codecov

codecov Bot commented Sep 25, 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 Δ
...s/Navigation/helpers/getMatchingFullScreenRoute.ts 80.76% <100.00%> (ø)
src/libs/Navigation/helpers/getStateFromPath.ts 95.83% <100.00%> (ø)
.../libs/Navigation/helpers/hasDifferentSplitScope.ts 100.00% <100.00%> (ø)
...libs/Navigation/helpers/linkTo/getMinimalAction.ts 100.00% <100.00%> (ø)
src/libs/Navigation/helpers/linkTo/index.ts 94.85% <100.00%> (ø)
...ibs/Navigation/helpers/replacePathInNestedState.ts 80.00% <100.00%> (ø)
...libs/Navigation/helpers/getAdaptedStateFromPath.ts 83.33% <77.77%> (ø)
src/libs/Navigation/helpers/getPathFromState.ts 86.90% <63.63%> (-9.05%) ⬇️
src/setup/addUtilsToWindow.ts 8.98% <3.77%> (-7.47%) ⬇️
... and 32 files with indirect coverage changes

Seatbelt-Operation: recovery-20260925-100768-knip-sign-1
Seatbelt-Operation: main-refresh-100768-20261014-sign-db381862
Seatbelt-Operation: main-refresh-100768-20261014-26cd-sign-53276dcc
Seatbelt-Operation: remaining-100768-oneoff-sign-c34274b3-afc2-4902-8306-972be711fed8

This branch has not been deployed

No deployments
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