Skip to content

Amount & Distance field do not load after returning online when commuter exclusion is enabled #103291

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.5.4-0
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #102258
Email or phone of affected tester (no customers): applausetester+ssndjois2jd1@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.5 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Enable commuterExclusions beta.
  • Home address - East 45th Street, Los Angeles, CA, 90012, US
  • Company address - 123 South Figueroa Street, Los Angeles, CA 90012
  • Enable Distance rates.
  • Enable Exclude usual commutes in Distance rates > Settings > Exclude commutes.
  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Click + > Track distance > Map.
  4. Enter home address and company address.
  5. Click Next > Create expense.
  6. Click + > Track distance > Map.
  7. Go offline.
  8. Click Reuse route.
  9. Select the previous route.
  10. On confirm page, go online.

Expected Result:

Amount and Distance field will load after returning online.

Actual Result:

Amount and Distance field do not load after returning online when commuter exclusion is enabled.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7279739_1791357449880.17.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7279739

Activity

  1. applause-bot commented on Oct 7, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/ded00425e1b3232bc997f4ac9df53d1eee1230753417ed3d2f74a12a2f1c66f5

  2. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 7, 2026
  3. melvin-bot commented on Oct 7, 2026

    @melvin-bot

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

  4. github-actions commented on Oct 7, 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 Oct 7, 2026

    @melvin-bot

    @Gonals @Pujan92 you have been assigned to this deploy blocker because you reviewed the offending PR: #102258

  6. melvin-bot commented on Oct 7, 2026

    @melvin-bot

    @ShridharGoel you have been assigned to this deploy blocker because you authored the offending PR: #102258

  7. melvin-bot commented on Oct 7, 2026

    @melvin-bot

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

  8. MelvinBot commented on Oct 7, 2026

    @MelvinBot
    Contributor

    Deploy Blocker Investigation

    Causing PR: [Payment due @Pujan92] Add Reuse route to the distance creation flow (high confidence). This is a frontend bug, so it stays a DeployBlockerCash.

    Root cause: That PR added !transaction?.isReusedRoute to shouldFetchRoute in src/hooks/useFetchRoute.ts:42-47. The guard also turns off the existing commuter-exclusion refetch. Under the home-and-office method, the confirm page hides Amount and Distance until a route response returns the commute decision. For a reused route picked offline, that fetch never runs after you reconnect.

    Recommendation: roll forward. The fix is a few lines; the PR touches 42 files. Revert it if no fix lands quickly.

    How it breaks
    1. selectReusableRoute (ReusableDistanceRoutes.ts:47-56) calls updateWaypoints. That clears routes and commuterExclusionPreview (Transaction.ts:467-496). It then sets isReusedRoute: true and the stored quantity.
    2. isCommuterExclusionPreviewPending (useDistanceRequestState.ts:119-127) is true: workspace chat, home-and-office method, route present (via quantity), and no preview. So Amount is blanked (useConfirmationAmount.ts:88-89) and the waypoints stay pending (DistanceRequestController.tsx:244-249).
    3. Only a route response supplies the preview. The new guard blocks both isCommuterExclusionPreviewStale (useFetchRoute.ts:41) and the confirm page's fetch (IOURequestStepConfirmation.tsx:629). isReusedRoute is cleared only when waypoints change, so the page stays pending.

    Why online seems to work (inferred, not tested): the Map screen stays mounted under Reuse route and runs the same hook (IOURequestStepDistanceMap.tsx:123). Between the two merges in step 1, isReusedRoute is briefly unset and routes is empty. Online, a fetch slips through in that window. Offline, the hook exits early (useFetchRoute.ts:50), and nothing refetches after you reconnect.

    Other PRs ruled out: I checked all 62 App PRs in the 9.5.4-0 checklist for distance, route, confirmation, and commuter files. The other matches were refactors or unrelated UI changes. None touch route fetching or the commuter preview. The commuter pending logic dates from early September; only this PR adds isReusedRoute.

    Suggested fix

    In src/hooks/useFetchRoute.ts, keep skipping routing for reused routes unless the home-and-office decision is missing:

    const hasCommuterExclusionPreview = DistanceRequestUtils.hasCommuterExclusionPreviewForPolicy(transaction, policy);
    const isCommuterExclusionPreviewStale = !!homeAndOfficeExclusionPolicyID && hasRoute && !hasRouteError && !hasCommuterExclusionPreview;
    // A reused route carries its distance, but under the home and office method only a route response carries the commute decision
    const isReusedRouteMissingCommuterExclusionPreview = !!homeAndOfficeExclusionPolicyID && !hasRouteError && !hasCommuterExclusionPreview;
    const shouldFetchRoute =
        isMapDistanceRequest &&
        (transaction?.isReusedRoute
            ? isReusedRouteMissingCommuterExclusionPreview
            : isRouteAbsentWithoutErrors || haveValidatedWaypointsChanged || isCommuterExclusionPreviewStale) &&
        !isLoadingRoute &&
        Object.keys(validatedWaypoints).length > 1;

    This cannot loop. isLoadingRoute blocks repeat requests, a success sets the preview, and a failure sets a route error. Add a useFetchRoute unit test: a reused route in a home-and-office workspace, offline then online, should call getRoute.


    Next steps: ShridharGoel, please fix this forward or revert the PR. Reply with @MelvinBot <your feedback> to refine this analysis.

  9. 3 remaining items

  10. melvin-bot commented on Oct 12, 2026

    @melvin-bot

    @Pujan92, @Gonals, @ShridharGoel Eep! 4 days overdue now. Issues have feelings too...

  11. melvin-bot commented on Oct 14, 2026

    @melvin-bot

    @Pujan92, @Gonals, @ShridharGoel Still overdue 6 days?! Let's take care of this!

  12. Gonals commented on Oct 15, 2026

    @Gonals
    Contributor

    @ShridharGoel, are you working on this?

  13. melvin-bot commented on Oct 20, 2026

    @melvin-bot

    @Pujan92, @Gonals, @ShridharGoel Huh... This is 4 days overdue. Who can take care of this?

  14. Gonals commented on Oct 21, 2026

    @Gonals
    Contributor

    @MelvinBot, is this still a bug?

  15. ShridharGoel commented on Oct 21, 2026

    @ShridharGoel
    Contributor

    Asking for a retest

  16. MelvinBot commented on Oct 21, 2026

    @MelvinBot
    Contributor

    Probably not. The fix merged on Oct 20 in Improvements and fixes in reuse routes feature and reached staging in 9.5.15-1. I couldn't confirm it in the app myself, so Applause should retest on 9.5.15-1 or later.

    Details
    • The fix: useFetchRoute no longer skips every reused route. For a reused route, it now fetches when the commute preview is missing, so Amount and Distance can load after you go back online (src/hooks/useFetchRoute.ts:45). This is the fix proposed earlier in this issue. The PR also adds a unit test for this case.
    • Why I couldn't retest: my web test account doesn't have the commuterExclusions beta, so "Exclude commutes" doesn't show up. Saving a home address also asks for a magic code that I can't get.

    view run · view recording

  17. m-natarajan commented on Oct 21, 2026

    @m-natarajan

    Distance and Amount load after going back online, Windows 11 Chrome, Google Pixel 7a / Android 17, iPhone 15 Pro / iOS 27.0.1, v9.5.15-2

    Expensify_103291_iOS.mp4
    Expensify_103291_Android.mp4
    Expensify_103291_Web.mp4
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.DailyKSv2Engineering

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions