Skip to content

[$250] Distance is saved with new value and old unit after changing rate with different unit #83652

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.26-7
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: #82257
Email or phone of affected tester (no customers): shdsubhiudhbuidshs@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.2 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Distance rates are enabled.
  • Workspace has at least two distance rates.
  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Create a manual distance expense.
  4. Open the expense.
  5. Click More > Split > Save.
  6. Go to workspace settings > Distance rates.
  7. Click Settings > Unit.
  8. Change to another unit.
  9. Open any distance split from Step 5.
  10. Click Amount > click highlighted row.
  11. Click Rate.
  12. Select another rate.
    → Distance field is converted to the correct value and unit.
  13. Click Save > Save.
  14. Click Distance field on the transaction thread.

Expected Result:

Distance field will show the correct value and unit in Step 12.

Actual Result:

The distance field shows the new value with old unit.
Distance editor further converts the value to the new unit.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7089781_1772165741560.17.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @suneox
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022027246443158234016
  • Upwork Job ID: 2027246443158234016
  • Last Price Increase: 2026-02-27

Activity

  1. added
    DeployBlockerCash
    Daily
    Bug
    DeployBlocker
    on Feb 27, 2026
  2. melvin-bot commented on Feb 27, 2026

    @melvin-bot

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

  3. melvin-bot commented on Feb 27, 2026

    @melvin-bot

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

  4. melvin-bot commented on Feb 27, 2026

    @melvin-bot

    Triggered auto assignment to @kadiealexander (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  5. github-actions commented on Feb 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.
  6. MelvinBot commented on Feb 27, 2026

    @MelvinBot
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    After splitting a distance expense and then changing the workspace's distance unit (e.g., mi → km), editing a split item's rate causes the distance value to be correctly converted but the old unit label to persist. For example, changing from a miles rate to a km rate converts 10 mi to 16.09, but saves it as 16.09 mi instead of 16.09 km. Opening the distance editor then further converts the already-converted value, producing a double-conversion (e.g., 25.90 km).

    What is the root cause of that problem?

    The root cause is that distanceUnit is not included in the SplitTransactionSplitParam API parameters, so the backend never receives the updated unit for child transactions during a split save.

    Here's the data flow:

    1. When the user changes the rate on a split item, setDraftSplitTransaction calls getUpdatedTransaction (TransactionUtils/index.ts:757-773), which correctly converts quantity and updates distanceUnit on the draft transaction.

    2. When saving the split edit, updateSplitExpenseField (Split.ts:2307-2310) correctly spreads the draft's customUnit (including the new distanceUnit) into the splitExpenses array.

    3. When the overall split is submitted, updateSplitTransactions constructs the API parameters at Split.ts:1091-1111:

      quantity: split.customUnit?.quantity,        // ✅ Included (converted value)
      customUnitRateID: split.customUnit?.customUnitRateID,  // ✅ Included
      // ❌ distanceUnit is NOT included
      
    4. The SplitTransactionSplitParam type (SplitTransactionParams.ts:3-22) does not have a distanceUnit field.

    5. While the client's optimistic update is correct (via buildOptimisticTransaction with the full customUnit at Split.ts:1187), the backend stores the child transaction with the old distanceUnit because it was never sent. When the server response returns, it overwrites the optimistic data, resulting in: new converted quantity + old unit.

    This causes the display to show 16.09 mi (interpreting the km-converted quantity as miles), and the distance editor to double-convert when opened.

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

    1. Add distanceUnit to SplitTransactionSplitParam in src/libs/API/parameters/SplitTransactionParams.ts:

      • Add distanceUnit?: string to the type definition
    2. Pass distanceUnit when constructing splits in src/libs/actions/IOU/Split.ts around line 1106:

      • Add distanceUnit: split.customUnit?.distanceUnit to the splits mapping alongside quantity and customUnitRateID
    3. Ensure the backend handles the distanceUnit parameter — the backend's SplitTransaction command handler needs to store the distanceUnit on each child transaction when provided.

    What alternative solutions did you explore? (Optional)

    An alternative would be to never store distanceUnit on individual transactions and always derive it from the policy's current distance unit. However, this would break for P2P distance transactions that may have a different unit than the policy, and for historical transactions where the policy unit has changed since creation. Explicitly passing distanceUnit in the API params is the safer, more explicit approach.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  7. added
    External
    on Feb 27, 2026
  8. added
    Help Wanted
    on Feb 27, 2026
  9. melvin-bot commented on Feb 27, 2026

    @melvin-bot

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

  10. changed the title [-]Distance is saved with new value and old unit after changing rate with different unit[/-] [+][$250] Distance is saved with new value and old unit after changing rate with different unit[/+] on Feb 27, 2026
  11. melvin-bot commented on Feb 27, 2026

    @melvin-bot
  12. removed
    Help Wanted
    on Feb 27, 2026
  13. removed
    External
    DeployBlocker
    DeployBlockerCash
    on Feb 27, 2026
  14. lakchote commented on Feb 27, 2026

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

Metadata

Metadata

Labels

BugEngineeringHourly

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions