Skip to content

[Odometer] Show discard changes modal when switching tabs#89612

Open
jakubkalinski0 wants to merge 38 commits into
Expensify:mainfrom
software-mansion-labs:jakubkalinski0/Odometer_show_discard_changes_modal_when_switching_tabs
Open

[Odometer] Show discard changes modal when switching tabs#89612
jakubkalinski0 wants to merge 38 commits into
Expensify:mainfrom
software-mansion-labs:jakubkalinski0/Odometer_show_discard_changes_modal_when_switching_tabs

Conversation

@jakubkalinski0

@jakubkalinski0 jakubkalinski0 commented May 5, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

This PR adds a feature we agreed on in this discussion to show a Discard Changes confirmation modal when the user tries to switch away from the Odometer tab to another tab with unsaved changes.

image

The tab-switch guard is generic, not odometer-specific. A new TabSwitchGuardContext lets any tab screen register getHasUnsavedChanges / onDiscard / onCancel callbacks keyed by tab name, and OnyxTabNavigator intercepts tabPress to show the shared "Discard changes?" modal - on confirm it runs onDiscard and then jumps to the target tab (it always jumps, even if onDiscard fails, surfacing a Growl error rather than stranding the user). It's wired through the existing useDiscardChangesConfirmation hook via a new onTabSwitchDiscard option that self-disables outside a tab navigator, and both the nav-away and tab-switch paths render an identical modal from getDiscardChangesModalConfig. On the Odometer tab, confirming clears the readings/images (or restores the confirmation-edit backup when editing) before the tab switch.

The discard diff is hardened against false positives: image changes use a re-mint-invariant identity (getOdometerImageIdentity, name|size|lastModified) that survives the draft round-trip but still detects a real swap, and the resync / unsaved-changes branching is extracted into unit-tested pure predicates (odometerResync.ts, getOdometerHasUnsavedChanges) that won't re-hydrate readings the user intentionally cleared.

Diff overview

24 files changed · +2097 / −197 - breakdown of main...HEAD at 290f76a

Tests vs. non-test source

Category Insertions %
Test files (8 files, 5 new) 1578 75%
Non-test source (14 files, 3 new) 516 25%
Config / wordlist data (2 files) 3 <1%
Total insertions 2097 100%

So roughly three quarters of the diff is tests - new unit + UI tests covering the generic tab-switch guard, the resync predicates, the odometer draft round-trip, and the edit-from-confirmation backup/restore path.

Inside the 519 non-test insertions

File Insertions Comment-only lines Actual code
OnyxTabNavigator.tsx (modified) 123 4 116 (+3 blank)
IOURequestStepDistanceOdometer.tsx (modified) 115 8 98 (+9 blank)
odometerResync.ts (NEW) 78 31 36 (+11 blank)
OdometerTransactionUtils.ts (modified) 67 16 42 (+9 blank)
TabSwitchGuardContext.tsx (NEW) 45 7 31 (+7 blank)
getDiscardChangesModalConfig.ts (NEW) 18 5 11 (+2 blank)
OdometerImageUtils.ts (modified) 18 7 10 (+1 blank)
useOdometerReadingsState.ts (modified) 14 13 1 (comment touch-up)
useDiscardChangesConfirmation/index.native.ts (modified) 10 2 7 (+1 blank)
useDiscardChangesConfirmation/index.ts (modified) 10 2 7 (+1 blank)
useDiscardChangesConfirmation/types.ts (modified) 6 4 1 (+1 blank)
OdometerDraft.ts (modified) 6 2 2 (+2 blank)
DistanceRequestStartPage.tsx (modified) 5 0 4 (+1 blank)
Attachment.ts (modified) 1 0 1
cspell.json + eslint.seatbelt.tsv (data) 3 0 3 (config)
Subtotals 519 101 367 (+48 blank, +3 config)

The tab-switch registration was added to both the web (index.ts) and native (index.native.ts) variants of useDiscardChangesConfirmation - they already had a platform split (usePreventRemove on native vs useBeforeRemove on web), and the new guard hooks into each identically. The new TabSwitchGuardContext and the OnyxTabNavigator integration are single cross-platform files: the guard lives at the navigator level, so there is no platform-specific behavior to split out.

Summary

Category Lines % of insertions
Tests 1578 75%
Comments / JSDoc in source 101 5%
Blank lines in source 48 2%
Config / wordlist data 3 <1%
Actual non-comment, non-blank source code 367 17.5%
Total insertions 2097 100%

Deletions (197 lines)

File(s) Deletions Nature
OnyxTabNavigator.tsx 42 return block restructured to add the provider + tabPress listener (rewrite, not removal)
IOURequestStepDistanceOdometer.tsx 41 old inline discard hook moved up and replaced by getOdometerHasUnsavedChanges
Tests (3 modified files) 52 updated assertions / helpers
useOdometerReadingsState.ts 20 resync effect relocated to the step + comment trims
OdometerTransactionUtils.ts 15 isOdometerDraftPendingHydration rewrite + comment removal
index.native.ts / index.ts 9 / 7 inline modal config replaced by shared getDiscardChangesModalConfig
OdometerImageUtils.ts 7 comment trim
DistanceRequestStartPage.tsx / Attachment.ts / eslint.seatbelt.tsv 2 / 1 / 1 misc

Bottom line: the PR is overwhelmingly additive. Of the 197 deletions, ~104 are source code and the rest are comments (39), tests (52), one blank line, and config. Crucially, almost none of those 104 lines are dead-code removal - they are rewrites/relocations: the OnyxTabNavigator return block was restructured to add the guard, and the odometer discard logic was moved out and re-expressed as pure predicates. Net new "real" source logic is roughly +263 lines (367 added − 104 removed), concentrated in the generic tab-guard wiring (OnyxTabNavigator + TabSwitchGuardContext), the odometerResync / getOdometerHasUnsavedChanges predicates, and the lastModified image-identity plumbing. Tests (1578 insertions / 52 deletions) are ~75% of the diff.

Fixed Issues

$ #89940
PROPOSAL: N/A

Tests

  1. Start a new expense and open the Distance request flow, then switch to the Odometer tab.
  2. Enter a start reading and/or end reading, and/or attach a start/end odometer image. Do not save.
  3. Tap a different tab (Map, Manual, or GPS) and verify that a "Discard changes?" confirmation modal appears.
  4. Tap Cancel and verify that you stay on the Odometer tab with your unsaved readings/images intact.
  5. Tap a different tab again, then tap the danger/confirm button in the modal.
  6. Verify that the modal closes, the Odometer tab is reset (readings cleared, images removed), and the app navigates to the tab you originally tapped.
  7. Back on the Odometer tab with empty readings/images, switch tabs and verify that no modal is shown and the tab switch happens immediately.
  8. Type a reading, then delete it so the field is empty. Verify the field stays empty (it does not snap back to the value you just cleared) and that switching tabs now shows no modal.
  9. Regression check the shared navigator: open another OnyxTabNavigator-based flow that does not register a guard (e.g. the Map/Manual distance tabs with no unsaved odometer changes) and verify tab switches happen immediately with no modal.
Odometer regression tests (optional)

Nav-away discard still works

  1. With unsaved odometer changes, use the in-app back button or press outside the RHP to leave the flow.
  2. Verify the existing "Discard changes?" modal still appears (this PR does not change nav-away behavior).

Save-for-later draft

  1. With odometer readings/images entered, tap Save for later, then reopen the flow.
  2. Switch tabs without making further edits and verify that NO modal appears (the hydrated draft equals the transaction, so it is not treated as an unsaved change).
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests

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 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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
untitled.webm
Android: mWeb Chrome
untitled2.webm
iOS: Native
Simulator.Screen.Recording.-.iPhone.16.Pro.Max.-.2026-06-16.at.23.05.25.mov
iOS: mWeb Safari
Simulator.Screen.Recording.-.iPhone.16.Pro.Max.-.2026-06-16.at.23.22.23.mov
MacOS: Chrome / Safari
Screen.Recording.2026-06-16.at.20.56.57.mov

@codecov

codecov Bot commented May 5, 2026

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
...ooks/useDiscardChangesConfirmation/index.native.ts 53.33% <100.00%> (+53.33%) ⬆️
src/libs/OdometerImageUtils.ts 77.27% <100.00%> (+39.77%) ⬆️
...uestStepDistance/hooks/useOdometerReadingsState.ts 100.00% <100.00%> (+1.81%) ⬆️
...uest/step/IOURequestStepDistance/odometerResync.ts 100.00% <100.00%> (ø)
src/pages/iou/request/DistanceRequestStartPage.tsx 0.00% <0.00%> (ø)
...ou/request/step/IOURequestStepDistanceOdometer.tsx 85.29% <96.00%> (+85.29%) ⬆️
...hangesConfirmation/getDiscardChangesModalConfig.ts 0.00% <0.00%> (ø)
src/hooks/useDiscardChangesConfirmation/index.ts 0.00% <0.00%> (ø)
src/libs/Navigation/TabSwitchGuardContext.tsx 84.61% <84.61%> (ø)
src/libs/actions/OdometerTransactionUtils.ts 54.80% <83.33%> (+37.76%) ⬆️
... and 1 more
... and 20 files with indirect coverage changes

@jakubkalinski0

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: 4a624d5330

ℹ️ 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/DistanceRequestStartPage.tsx Outdated
@jakubkalinski0

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: 31b9b37c2f

ℹ️ 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/DistanceRequestStartPage.tsx Outdated
Comment thread src/pages/iou/request/step/confirmation/ReceiptFileValidator.tsx Outdated
@jakubkalinski0

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: b2690b40a8

ℹ️ 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/OdometerReceiptStitcher.tsx Outdated
@jakubkalinski0

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: b2690b40a8

ℹ️ 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/ReceiptFileValidator.tsx Outdated
@jakubkalinski0

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: bd1d392ced

ℹ️ 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/DistanceRequestStartPage.tsx Outdated
@jakubkalinski0

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: f9086f72ef

ℹ️ 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/IOURequestStepDistanceOdometer.tsx
@jakubkalinski0

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: 4f59a798f4

ℹ️ 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/DistanceRequestStartPage.tsx Outdated
@jakubkalinski0

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: 62149d8334

ℹ️ 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/IOURequestStepDistanceOdometer.tsx
@jakubkalinski0

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: 62149d8334

ℹ️ 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/IOURequestStepDistanceOdometer.tsx
@jakubkalinski0

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

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

@jakubkalinski0 jakubkalinski0 marked this pull request as ready for review May 11, 2026 21:27
@jakubkalinski0 jakubkalinski0 requested review from a team as code owners May 11, 2026 21:27
@melvin-bot melvin-bot Bot requested review from DylanDylann and heyjennahay and removed request for a team and heyjennahay May 11, 2026 21:27
…itch

Removes the browser-Back-button discard mechanism introduced in 4ab9a73:
the tab-history replacement router, goForwardInBrowserHistory helper, and the
page-level useActiveTabGuardDiscardConfirmation hook. Restores the per-step
useDiscardChangesConfirmation (header/hardware back) and keeps the core
tab-switch discard modal and the resync guard untouched.
@jakubkalinski0

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 08b559197d

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

@TaduJR

TaduJR commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Took a deep look at the PR since our flows now compose. It's great!

But one architectural thought: DistanceTabGuardContext is a second guard system parallel to useDiscardChangesConfirmation the odometer screen declares its unsaved state to two APIs, and the modal config is hand-copied into the page (already diverged: the hook restores input focus on Cancel, the tab modal doesn't). Alternative shape: OnyxTabNavigator owns a generic guard registry + the tabPress listener, and useDiscardChangesConfirmation registers into it when rendered under a tab screen. One registration per screen, modal config in one place, and any tabbed flow gets this for free imo.

Smaller things:

  • screenListeners accepts the function form ({navigation}) => ({tabPress: …}), so the tabBar wrapper and the two refs sniffing its props can go.
  • activeGuardRef is a single slot with last-writer-wins: visited tabs stay mounted, so a second registering tab would silently disarm the guard. A Map keyed by tab name removes that class.
  • handleTabSwitchDiscard rejections only Log.warn the user confirmed Discard, a partial reset may have run, and they get no feedback.
  • The seatbelt entries and the exhaustive-deps suppression look avoidable: typed factories for the test casts, the waitForBatchedUpdates().then() idiom for async/await, and including the omitted deps in the resync effect refs and setters are stable, so it won't re-run more often (and if it did, that's a hook-stability bug worth surfacing).
  • Also some comments are mile-long, I think we can compress them right, and remove unnecessary ones to reduce the diff like obvious ones that the codes are self explanatory by them selfs.

@jakubkalinski0

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: dd02532305

ℹ️ 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/OdometerImageUtils.ts Outdated
…ories

Add a Growl.error toast in OnyxTabNavigator when a tab-switch onDiscard
rejects (alongside the existing Log.warn + always-jump), so a failed reset
isn't silent.

Replace remaining no-unsafe-type-assertion casts in the odometer tests with
typed factories: OdometerDraft literals are cast-free (all-optional), and
Transaction fixtures build on createRandomTransaction. Removes the seatbelt
rows for the Backup/UtilsTest/ReadingsState/TransactionBackup tests and
trims the two DISTANCE_CREATE route casts to one each.
@jakubkalinski0

Copy link
Copy Markdown
Contributor Author

@codex review

@jakubkalinski0

Copy link
Copy Markdown
Contributor Author

@TaduJR Great input there! I liked your idea and refactored the code in that direction. Could you please check it out if it's more to your liking?

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 290f76a7dc

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

@jakubkalinski0

Copy link
Copy Markdown
Contributor Author

@DylanDylann All yours! (Don't get scared about the LOC, it's mostly tests 😅 )

"../../tests/ui/ForYouSectionTest.tsx" "@typescript-eslint/no-unsafe-type-assertion" 3
"../../tests/ui/IOURequestStartPageTest.tsx" "@typescript-eslint/no-unsafe-type-assertion" 2
"../../tests/ui/IOURequestStepAmountDraftTest.tsx" "@typescript-eslint/no-unsafe-type-assertion" 2
"../../tests/ui/IOURequestStepDistanceOdometerNextSyncTest.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1

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 need to update it manually. It will be updated automatically when it is merged into main.

Comment on lines +34 to +38
return register({
tabName,
getHasUnsavedChanges: () => guardCallbacksRef.current.getHasUnsavedChanges(),
onDiscard: () => guardCallbacksRef.current.onDiscard?.(),
onCancel: () => guardCallbacksRef.current.onCancel?.(),

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.

@jakubkalinski0 When switching away from the distance odometer tab, this tab isn't always unmounted

Screen.Recording.2026-06-17.at.16.39.49.mov

odometerEndImage?: string;

/** `lastModified` of the start image, preserved so the re-minted image keeps its identity (getOdometerImageIdentity) */
odometerStartImageLastModified?: number;

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.

@jakubkalinski0 Why do we need this field?

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.

4 participants