Skip to content

Report - Default rate still visible for some time after creating expense with different rate #98239

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.52-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #97517
Email or phone of affected tester (no customers): ibellicotest+2766@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Motorola MotoG60 / Android 12 (Hybrid app) - Windows 11 / Chrome
App Component: Money Requests

Action Performed:

Prerequisite: Account has at least one workspace.
Prerequisite 2: At least one distance rate created apart from "Default"

  1. Open the staging.new.expensify.com website.
  2. Open any workspace chat.
  3. Create a map distance expense with a rate different from default.
  4. Once expense is created, open report quickly.
  5. Note that while expense is still loading, "Default rate" is still visible on "Rate" field.
  6. Note that after some time, rate changes to the selected one.

Expected Result:

Distance expense report should automatically display the selected rate.

Actual Result:

"Default Rate" is still visible on report for some time, after creating a map distance expense with a different rate.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7230606_1786407603679.Default.1.mp4

View all open jobs on GitHub

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

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

Activity

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

  3. melvin-bot commented on Aug 11, 2026

    @melvin-bot

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

  4. melvin-bot commented on Aug 11, 2026

    @melvin-bot

    @Valforte @abdulrahuman5196 you have been assigned to this deploy blocker because you reviewed the offending PR: #97517

  5. melvin-bot commented on Aug 11, 2026

    @melvin-bot

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

  6. melvin-bot commented on Aug 11, 2026

    @melvin-bot

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

  7. github-actions commented on Aug 11, 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.
  8. MelvinBot commented on Aug 11, 2026

    @MelvinBot
    Contributor

    🔍 Investigation Summary

    Classification: Frontend bug (App-side optimistic/loading-state display; self-corrects once the server response arrives)
    Causing PR: None confidently identified. The auto-assigned #97517 — "Optimistically add message for distance rate changes" by @Gonals — is exonerated (Low confidence it is the cause; see below).
    Related Issues: none

    Recommendation: NEEDS INVESTIGATION

    Reverting the auto-assigned PR #97517 would not fix this bug — it only touches the distance-rate edit flow, while this bug is in the map-distance creation/loading flow. The symptom is a transient, self-correcting display gap during the MapBox route-computation window, so if a fix is pursued it should be a targeted roll-forward in the create-time rate resolution, not a revert. Keeping DeployBlockerCash because this is a frontend bug and, per policy, the issue is not reproducible on production.

    Assigned: none added — no causing PR reaches medium confidence, so no new contributors are assigned (the existing melvin auto-assignees remain).
    Labels: No changes. DeployBlockerCash kept (frontend bug, staging-only repro, must not be removed). No DeployBlocker (web) label is present.

    📋 Detailed Analysis

    Evidence — why #97517 is NOT the cause

    • Optimistically add message for distance rate changes #97517 modifies only four files, all in the edit path: src/libs/TransactionUtils/index.ts (getUpdatedTransaction + new hasLocallyKnownDistance) and src/libs/actions/IOU/UpdateMoneyRequest.ts (getUpdateMoneyRequestParams / getUpdateTrackExpenseParams), plus two test files.
    • Its behavior change: when a user edits the rate of an already-existing distance expense while waypoints are still pending, and the route distance is already known locally, it now builds an optimistic MODIFIED_EXPENSE message. This is the "change rate on an existing expense" flow.
    • The reported bug is the creation flow: "Create a map distance expense with a rate different from default … open report quickly … Default rate is visible while loading." Optimistically add message for distance rate changes #97517 touches neither MoneyRequestView (the Rate field renderer) nor the create-time optimistic transaction builder, so it cannot explain a wrong rate shown right after creation.
    • The bug reproduces on staging but not production, i.e. a regression in the 9.4.52 deploy, but the two distance PRs in that checklist — Optimistically add message for distance rate changes #97517 (edit flow) and Fix offline self-DM distance rate resolution #96903 "Fix offline self-DM distance rate resolution" (guarded by action === CONST.IOU.ACTION.SUBMIT, i.e. the self-DM move flow, and it adds rate propagation rather than removing it) — neither cleanly matches the "create a map distance expense in a workspace chat" repro path. Hence Low confidence in any specific causing PR.

    Verification

    • Rate field is rendered by src/components/ReportActionItem/MoneyRequestView.tsx, which calls DistanceRequestUtils.getRate(...):
      name: rateName,
      } = DistanceRequestUtils.getRate({
      transaction: updatedTransaction ?? transaction,
      policy: distanceOriginalPolicy ?? policy,
      personalPolicyOutputCurrency: personalPolicy?.outputCurrency,
      });
      const distance = getDistanceInMeters(transactionBackup ?? updatedTransaction ?? transaction, unit);
      const currency = transactionCurrency ?? CONST.CURRENCY.USD;
      const hasRequiredCompanyCardViolation = transactionViolations.some((violation) => violation.name === CONST.VIOLATIONS.COMPANY_CARD_REQUIRED);
      const isCustomUnitOutOfPolicy =
      (transactionViolations.some((violation) => violation.name === CONST.VIOLATIONS.CUSTOM_UNIT_OUT_OF_POLICY) || (isDistanceRequest && !rate)) && !isTrackExpense;
      const calculateFromTransactionData = isTrackExpense && !rate;
      const distanceUnit = calculateFromTransactionData ? transaction?.comment?.customUnit?.distanceUnit : unit;
      const distanceRate = calculateFromTransactionData ? (transactionAmount ?? 0) / (transaction?.comment?.customUnit?.quantity ?? 1) : rate;
      let rateToDisplay = DistanceRequestUtils.getRateForExpenseDisplay(
    • The displayed rate name comes from getRate in src/libs/DistanceRequestUtils.ts:
      const customUnitRateID = getRateID(transaction);
      const customMileageRate =
      (customUnitRateID && (mileageRates?.[customUnitRateID] ?? mileageRatesForMovingExpenses?.[customUnitRateID])) ||
      (isUnreportedExpense || isMovingTransactionFromTrackExpense ? undefined : defaultMileageRate);
      const mileageRate = isCustomUnitRateIDForP2P(transaction) || isFakeP2PRate ? getRateForP2P(policyCurrency, transaction) : customMileageRate;
    • Optimistically add message for distance rate changes #97517's changed files (TransactionUtils/index.ts getUpdatedTransaction/hasLocallyKnownDistance, UpdateMoneyRequest.ts) are in the update path and are not on this render path.

    Root Cause

    During the map-distance creation window the optimistic transaction has pendingFields.waypoints = ADD, amount = 0, and the route is still being computed by MapBox. getRate resolves the rate as:

    const customMileageRate =
        (customUnitRateID && (mileageRates?.[customUnitRateID] ?? mileageRatesForMovingExpenses?.[customUnitRateID])) ||
        (isUnreportedExpense || isMovingTransactionFromTrackExpense ? undefined : defaultMileageRate);
    

    (

    const customUnitRateID = getRateID(transaction);
    const customMileageRate =
    (customUnitRateID && (mileageRates?.[customUnitRateID] ?? mileageRatesForMovingExpenses?.[customUnitRateID])) ||
    (isUnreportedExpense || isMovingTransactionFromTrackExpense ? undefined : defaultMileageRate);
    const mileageRate = isCustomUnitRateIDForP2P(transaction) || isFakeP2PRate ? getRateForP2P(policyCurrency, transaction) : customMileageRate;
    )

    When the selected rate cannot be resolved from the transaction/policy at that instant (customUnitRateID from getRateID(transaction) not yet populated on comment.customUnit.customUnitRateID, or the rate not yet present in the derived mileageRates), this expression falls back to defaultMileageRate, so the Rate field shows "Default rate". Once the server response finalizes the transaction (rate ID + route), getRate returns the selected rate and the field self-corrects. This is a transient optimistic-data gap in the create/loading window, not corrupted saved data — the persisted expense ends up with the correct rate.

    Note for BugZero

    Because the wrong value is shown only briefly during the route-loading window and auto-corrects (no data loss, correct rate is saved), this may be a DEMOTE candidate. Flagging rather than acting on it, since the label decision here is conservative: DeployBlockerCash stays until an owner confirms severity and the true optimistic-data gap.

  9. 20 remaining items

  10. changed the title [-]Report - Default rate still visible for some time after creating expense with different rate[/-] [+][HOLD for #98194] Report - Default rate still visible for some time after creating expense with different rate[/+] on Aug 24, 2026
  11. MelvinBot commented on Aug 24, 2026

    @MelvinBot
    Contributor

    Done ✅

    • Title: prefixed with [HOLD for #98194] → now [HOLD for #98194] Report - Default rate still visible for some time after creating expense with different rate
    • Label: removed Daily, added Weekly

    view run

  12. melvin-bot commented on Sep 16, 2026

    @melvin-bot

    This issue has not been updated in over 15 days. @Valforte, @Gonals, @abdulrahuman5196 eroding to Monthly issue.

    P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

  13. abdulrahuman5196 commented on Sep 26, 2026

    @abdulrahuman5196
    Contributor

    @MelvinBot Remove the hold, the hold PR is merged

  14. changed the title [-][HOLD for #98194] Report - Default rate still visible for some time after creating expense with different rate[/-] [+]Report - Default rate still visible for some time after creating expense with different rate[/+] on Sep 26, 2026
  15. MelvinBot commented on Sep 26, 2026

    @MelvinBot
    Contributor

    Done ✅ I removed the hold.

    • Title: removed the [HOLD for #98194] prefix. The title is now Report - Default rate still visible for some time after creating expense with different rate.
    • Label: removed Monthly and added Daily.

    The fix for Distance - Rate is not selected when distance expense is created offline merged in Keep the selected distance rate on offline-created distance expenses on 2026-09-14. You can now retest this issue on staging to see if that PR fixed it too.

  16. abdulrahuman5196 commented on Sep 26, 2026

    @abdulrahuman5196
    Contributor

    This is not repro anymore, we can close this issue

    Screen.Recording.2026-09-26.at.12.03.47.PM.mov
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.DailyKSv2EngineeringExternalAdded 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