Skip to content

Distance rate - Can't enable distance rate #97776

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.49-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/folder/13176744/test-cases/41237134
Email or phone of affected tester (no customers): - applausetester+84206@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Windows 11 / Chrome
App Component: Other

Action Performed:

  1. Login with new account
  2. Create a new workspace
  3. Navigate to more features > Enable Distance rates (Or any feature like accounting, Expensify card, HR, Tags...)

Expected Result:

The features can be enabled and appear in the workspace settings page

Actual Result:

Feature can't be enabled. Togle became disabled automatically

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7225412_1785836466069.bandicam_2026-08-04_12-39-47-677.mp4

View all open jobs on GitHub

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

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mountiny

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Aug 4, 2026
  2. applause-bot commented on Aug 4, 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/370aa64c08162903250ec549a9e6f6190853327b551a133fa39c968b0e32faf0

  3. MelvinBot commented on Aug 4, 2026

    @MelvinBot
    Contributor

    Issue Analysis

    Root Cause: This is a backend issue, not an App bug. When you enable Distance rates, the App optimistically flips the toggle on and sends the EnablePolicyDistanceRates command. The backend accepts the request but does not persist areDistanceRatesEnabled = true (it signals a failure jsonCode and/or pushes the flag back as false), so the App rolls the toggle back to OFF via its failureData. I confirmed this live on web: creating a fresh workspace and toggling Distance rates fires EnablePolicyDistanceRates (HTTP 200 — expected for all Expensify API calls regardless of outcome), yet the toggle reverts to OFF every time and no Distance rates tab is added.

    Where the fix lives: Outside this repo — in the backend EnablePolicyDistanceRates command handler (Auth/Web-Expensify). The App client code is correct and has no path to fix this. This needs an internal engineer with backend access to investigate why the command isn't persisting the enabled state on newly-created workspaces (likely a missing default distance customUnit/rate precondition or a rolled-back write).

    The applause-bot reproduction confirms it's broken in staging and production on Web (Chrome), macOS, and iOS — consistent with a server-side cause hitting all platforms.

    Investigation details & evidence

    Client-side flow (all public App code, confirmed correct):

    • The toggle's onToggle just calls enablePolicyDistanceRates(policyID, isEnabled, distanceRateCustomUnit) with no upgrade/billing gate — WorkspaceMoreFeaturesPage/index.tsx:545-550.
    • The toggle's displayed state is driven by policy?.areDistanceRatesEnabled — index.tsx:541.
    • The action sets areDistanceRatesEnabled: true optimistically, keeps it true on success, and only writes it back to false in failureData — DistanceRate.ts:54-133 (revert at L81-L92). The customUnits manipulation only runs when disabling (if (!enabled && customUnit)), so it plays no part in the enable failure, and there is no client-side validation blocking the enable. The only way the flag ends up false after a completed request is a server-signaled failure.

    Live web reproduction (this run): Created a new workspace → More features → tapped Distance rates. The toggle reverted to OFF each of 3 attempts; POST /api/EnablePolicyDistanceRates returned status 200 each time, but the flag never stuck and no Distance rates nav tab appeared. A generic "add payment method" free-trial nag surfaced on one attempt — this appears incidental to the trial state, not the toggle mechanism.

    Distance rates toggle OFF before tapping:
    Distance rates toggle OFF before tapping

    Toggle reverted to OFF immediately after enabling:
    Distance rates toggle reverted to OFF immediately after enabling

    Free-trial "add payment method" nag seen during testing (incidental):
    Add payment method billing nag surfaced during the test

    Not accessible in this run: Production VictoriaLogs (CI runner has no VL access), so I could not read the exact backend jsonCode/error. An internal engineer should query the EnablePolicyDistanceRates command for a freshly-created workspace's policyID around the report date to see the failure code / precondition.

    Alternative explanations considered & ruled out: (1) A client upgrade/subscription gate reverting the toggle — ruled out, distance rates has no such gate in the handler. (2) The customUnits rate logic corrupting state on enable — ruled out, that branch only runs on disable. (3) A flaky one-off — ruled out, it reproduced 3/3 and applause-bot reproduced across staging/prod and multiple platforms.

    Confidence: Medium-High. Client behavior is confirmed correct by both static analysis and live reproduction; the backend cause is strongly implied by "request completes but flag doesn't persist," but the exact backend precondition needs internal logs/code to pin down.


    Next Steps: This requires a backend fix outside Expensify/App, so it can't be implemented from this repo. An internal engineer should investigate the EnablePolicyDistanceRates command's handling of newly-created workspaces. Reply with @MelvinBot <feedback> to refine this analysis.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Aug 4, 2026
  5. melvin-bot commented on Aug 4, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @ChavdaSachin (External)

  6. melvin-bot commented on Aug 4, 2026

    @melvin-bot
  7. melvin-bot commented on Aug 7, 2026

    @melvin-bot

    @ChavdaSachin Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  8. melvin-bot commented on Aug 11, 2026

    @melvin-bot

    @ChavdaSachin Still overdue 6 days?! Let's take care of this!

  9. melvin-bot commented on Aug 13, 2026

    @melvin-bot

    @ChavdaSachin 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

  10. melvin-bot commented on Aug 17, 2026

    @melvin-bot

    @ChavdaSachin 12 days overdue. Walking. Toward. The. Light...

  11. melvin-bot commented on Aug 18, 2026

    @melvin-bot

    @ChavdaSachin this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

  12. ChavdaSachin commented on Aug 19, 2026

    @ChavdaSachin
    Contributor

    🎀 👀 🎀 C+ reviewed
    BE issue

  13. melvin-bot commented on Aug 19, 2026

    @melvin-bot

    Triggered auto assignment to @mountiny, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

  14. m-natarajan commented on Aug 19, 2026

    @m-natarajan

    @mountiny Added the email associated with this issue applausetester+84206@applause.expensifail.com

  15. m-natarajan commented on Aug 19, 2026

    @m-natarajan

    Chrome / v9.4.56-0
    Passed

    REC-20260819215636.mp4
    Recording.3386.mp4
  16. mountiny commented on Aug 19, 2026

    @mountiny
    Contributor

    Perfect, thank you

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.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions