Skip to content

Distance - Wrong modal when member without address opens Track distance flow #99711

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.4.63-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: #94316
Email or phone of affected tester (no customers): applausetester+sddd1j1d@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:

  • Log in with Expensifail accounts.
  • Add an address to workspace.
  • Enable Distance rates.
  • Invite another member without address to the workspace.
  1. Go to staging.new.expensify.com
  2. [Member] Go to the invited workspace chat.
  3. [Member] Create a manual distance expense.
  4. [Admin] Go to Distance rates > Settings > Exclude commutes > select Calculate by home and office > Save.
  5. [Member] Click + > Track distance.

Expected Result:

Add Home Address modal will open.

Actual Result:

"Map or GPS distance required" modal opens.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7244677_1787869829240.3.mp4
Bug7244677_1787871022212.3.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Mita Rachim
Bug ID: 7244677

Activity

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

    @melvin-bot

    @Gonals recently merged #94316, but they are OOO right now, so I'll auto-assign someone else.

  3. github-actions commented on Aug 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.
  4. melvin-bot commented on Aug 27, 2026

    @melvin-bot

    Triggered auto assignment to @jasperhuangg (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  5. melvin-bot commented on Aug 27, 2026

    @melvin-bot

    @robertjchen @JmillsExpensify @fedirjh you have been assigned to this deploy blocker because you reviewed the offending PR: #94316

  6. melvin-bot commented on Aug 27, 2026

    @melvin-bot

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

  7. melvin-bot commented on Aug 27, 2026

    @melvin-bot

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

  8. MelvinBot commented on Aug 27, 2026

    @MelvinBot
    Contributor

    🔍 Investigation Summary

    Classification: Frontend bug
    Causing PR: #94316 - "Allow Home and Office Commuter exclusions" by Gonals (High confidence)
    Related Issues: N/A

    Recommendation: ROLL FORWARD

    The bug is a two-line condition-ordering mistake in a single new hook; a targeted reorder fixes it, whereas reverting #94316 would tear out an entire 40+ file feature (with a held backend dependency) for a trivial defect.

    Assigned: Gonals (PR author), robertjchen, JmillsExpensify, fedirjh (approving reviewers) — already auto-assigned to this issue
    Labels: No change. DeployBlockerCash is kept (App deploy is blocked). No DeployBlocker label is present, so nothing to remove.

    📋 Detailed Analysis

    Evidence

    • PR Allow Home and Office Commuter exclusions #94316 introduces the entire commuter-exclusion guard feature, including the new hook src/hooks/useCommuterExclusionGuard.ts (+87/-23) and its test tests/unit/hooks/useCommuterExclusionGuard.test.ts — the exact code that decides between the "Add Home Address" modal and the "Map or GPS distance required" modal.
    • The bug reproduces on staging only and is N/A on production because this is a brand-new feature shipped by Allow Home and Office Commuter exclusions #94316 — the feature did not exist before this PR.
    • The merge date (2026-08-27) matches when the blocker was reported (same day).

    Verification

    Root Cause

    In getGuardReason the checks run in the wrong precedence order (lines 82-88):

    if (isManualDistanceRequest || isOdometerDistanceRequest) {
        return 'mapOrGpsRequired';
    }
    
    if (isDistanceRequest && policiesWithCommuterExclusions[policyIDToCheck].method === CONST.POLICY.COMMUTER_EXCLUSION_METHOD.HOME_AND_OFFICE && !hasHomeAddress) {
        return 'homeAddressRequired';
    }

    Walking the repro:

    1. Step 3 — the member creates a manual distance expense, which sets NVP_LAST_DISTANCE_EXPENSE_TYPE to DISTANCE_MANUAL.
    2. Step 5 — the member clicks + → Track distance. TrackDistanceMenuItem reads that stale lastDistanceExpenseType and calls the guard with isManualDistanceRequest: true and isDistanceRequest: true.
    3. In getGuardReason, the first if matches on isManualDistanceRequest and returns 'mapOrGpsRequired', short-circuiting before the homeAddressRequired branch is ever evaluated.

    For a HOME_AND_OFFICE policy where the member has no home address, adding the home address is the prerequisite that must be surfaced first, but the broader manual/odometer short-circuit wins, so the wrong ("Map or GPS distance required") modal appears.

    The existing unit test at tests/unit/hooks/useCommuterExclusionGuard.test.ts covers isDistanceRequest: true alone (correctly returns homeAddressRequired) but never the isDistanceRequest: true + isManualDistanceRequest: true + home-and-office + no-address combination, which is exactly the gap the bug falls into.

    Suggested fix (roll forward)

    Evaluate the homeAddressRequired branch before the mapOrGpsRequired branch, so a missing home address on a home-and-office policy takes precedence regardless of the last expense type. Add a unit test for the combined isDistanceRequest + isManualDistanceRequest + home-and-office + missing-address case to lock in the ordering.


    view run

  9. m-natarajan commented on Aug 28, 2026

    @m-natarajan

    Chrome / v9.4.63-0
    N/A for public account

    bandicam.2026-08-28.22-42-54-883.mp4
  10. m-natarajan commented on Aug 28, 2026

    @m-natarajan

    N/A for public account
    Removed the Deploy Blocker label as per this comment

  11. added and removed on Sep 7, 2026
  12. fedirjh commented on Sep 7, 2026

    @fedirjh
    Contributor

    This was fixed in #99433.

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