Skip to content

[Due for payment 2026-05-11] Odometer-Discard changes modal is shown after refreshing the browser and navigating away #89008

Closed

Description

@mitarachim

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.3.62-10
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #88702
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: MacBook Air 15.7.4 Chrome
App Component: Money Requests

Action Performed:

  1. Open the NewDot app on web
  2. Click the FAB -> Track Distance -> switch to the Odometer tab
  3. Enter a start odometer reading and capture a start odometer image
  4. Enter an end odometer reading and capture an end odometer image
  5. Refresh the browser
  6. Click outside the modal or on the back button

Expected Result:

"Discard changes?" modal does not appear since the changes were removed after refreshing the browser

Actual Result:

"Discard changes?" modal appears when navigating away from Odometer flow after refreshing the browser

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7139609_1777324311911.Discard_changes.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @DylanDylann

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    DeployBlockerIndicates it should block deploying the API
    on Apr 27, 2026
  2. melvin-bot commented on Apr 27, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #88702

  3. melvin-bot commented on Apr 27, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  4. github-actions commented on Apr 27, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  5. melvin-bot commented on Apr 27, 2026

    @melvin-bot

    ⚠️ Looks like this issue was linked to a Deploy Blocker here

    If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

    If a regression has occurred and you are the assigned CM follow the instructions here.

    If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

  6. MelvinBot commented on Apr 27, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    A race condition between async Onyx state clearing and synchronous component initialization after browser refresh.

    When the user refreshes on the confirmation screen, useRestartOnOdometerImagesFailure detects expired blob URLs and calls clearOdometerDraftTransactionState followed immediately by navigateToStartMoneyRequestStep. However, clearOdometerDraftTransactionState fires five separate async Onyx.merge calls and returns void — it does not await completion.

    When IOURequestStepDistanceOdometer re-mounts, the initial refs useEffect sets initialStartReadingRef/initialEndReadingRef to '' (Onyx data hasn't arrived yet). Then the stale transaction draft (with old odometer readings) arrives from Onyx before the null merges flush, and the second useEffect populates startReadingRef/endReadingRef with those stale values. Now getHasUnsavedChanges returns true because startReadingRef !== initialStartReadingRef, triggering the discard modal.

    What changes do you think we should make in order to solve the problem?

    Make clearOdometerDraftTransactionState return Promise.all of its Onyx operations, and await it in useRestartOnOdometerImagesFailure before calling navigateToStartMoneyRequestStep. This ensures the draft transaction state is fully cleared before the odometer component re-mounts, so the initial refs and current refs will both be empty — no false dirty state.

    What alternative solutions did you explore? (Optional)

    1. Pass a route param from the hook to signal "redirected from blob failure" and have the odometer component skip the discard check when that param is set. This works but adds coupling between the navigation param and the discard logic.
    2. Delay the initial refs initialization until Onyx has settled (e.g., wait a tick). This is fragile and timing-dependent.

    The await approach is cleanest because it fixes the root cause (navigating before state is cleared) rather than working around the symptom.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  7. 10 remaining items

  8. changed the title [-]Odometer-Discard changes modal is shown after refreshing the browser and navigating away[/-] [+][Due for payment 2026-05-11] Odometer-Discard changes modal is shown after refreshing the browser and navigating away[/+] on May 4, 2026
  9. melvin-bot commented on May 4, 2026

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  10. melvin-bot commented on May 4, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.65-6 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2026-05-11. 🎊

    For reference, here are some details about the assignees on this issue:

  11. melvin-bot commented on May 4, 2026

    @melvin-bot

    @DylanDylann The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  12. arosiclair commented on May 4, 2026

    @arosiclair
    Contributor

    I believe this is done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions