Skip to content

[Awaiting Checklist] [$250] Track distance -In self DM, distance edited is not updated in 1:1 chat but updated amount is shown. #76712

Closed

Description

@jponikarchuk

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: V9 2.71-5
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/13176877/test-cases/41237352
Email or phone of affected tester (no customers): dreamnitethedragon+yydyd373@gmail.com
Issue reported by: Applause Internal Team
Device used: Redminote 10S Android 13
App Component: Money Requests

Action Performed:

  1. Launch app
  2. Open self DM
  3. Create a track manual distance
  4. Tap submit to someone
  5. Select a 1:1 user
  6. In confirm page, edit the distance
  7. Note amount and distance updated
  8. Tap create expense
  9. Open the expense
  10. Note old distance is shown and only updated amount is shown

Expected Result:

In self DM, distance edited must be updated in 1:1 chat like updated amount is shown.

Actual Result:

In self DM, distance edited is not updated in 1:1 chat but updated amount is shown.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021996901400348600339
  • Upwork Job ID: 1996901400348600339
  • Last Price Increase: 2025-12-05
  • Automatic offers:
    • thelullabyy | Contributor | 109957861
Issue OwnerCurrent Issue Owner: @
Issue OwnerCurrent Issue Owner: @garrettmknight

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Dec 4, 2025
  2. melvin-bot commented on Dec 4, 2025

    @melvin-bot

    Triggered auto assignment to @garrettmknight (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.

  3. thelullabyy commented on Dec 4, 2025

    @thelullabyy
    Contributor

    Proposal

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

    In self DM, distance edited is not updated in 1:1 chat but updated amount is shown.

    What is the root cause of that problem?

    When users create the track expense, we’ll generate the merchant based on distance, rate and unit like distance @ rate / unit

    If users move it to someone but change the distance or rate, we still use the generated merchant above, so it’s not correct

    merchant: isTestReceipt ? CONST.TEST_RECEIPT.MERCHANT : item.merchant,

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

    We should generate the new merchant if it’s the manual distance request in

                    let merchantToUse = isTestReceipt ? CONST.TEST_RECEIPT.MERCHANT : item.merchant;
                    if (!isTestReceipt && isManualDistanceRequestTransactionUtils(item)) {
                        const distance = item.comment?.customUnit?.quantity;
                        const unit = item.comment?.customUnit?.distanceUnit;
                        const rate = item.comment?.customUnit?.defaultP2PRate;
                        if (distance && unit && rate) {
                            // Convert distance to meters
                            const distanceInMeters = DistanceRequestUtils.convertToDistanceInMeters(distance, unit);
                            merchantToUse = DistanceRequestUtils.getDistanceMerchant(true, distanceInMeters, unit, rate, item.currency ?? CONST.CURRENCY.USD, translate, toLocaleDigit);
                        }
                    }
    

    Then use merchantToUse in

    merchant: isTestReceipt ? CONST.TEST_RECEIPT.MERCHANT : item.merchant,

    It’ll work in offline mode because BE will return the outdated distance, rate in transaction
    To fix this issue, we should pass the new distance, rate and unit to BE as well

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

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

    @melvin-bot
  6. changed the title [-]Track distance -In self DM, distance edited is not updated in 1:1 chat but updated amount is shown.[/-] [+][$250] Track distance -In self DM, distance edited is not updated in 1:1 chat but updated amount is shown.[/+] on Dec 5, 2025
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Dec 5, 2025
  8. melvin-bot commented on Dec 5, 2025

    @melvin-bot

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

  9. Nodebrute commented on Dec 6, 2025

    @Nodebrute
    Contributor

    Proposal

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

    In self DM, distance edited is not updated in 1:1 chat but updated amount is shown

    What is the root cause of that problem?

    While moving the expense from self dm and changing the waypoint the transaction?.routes?.route0?.distance changes but merchant stays the same. We don't have the logic that watches for distance change

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

    Add a useEffect that in IOURequestStepDistance.tsx that watches transaction?.routes?.route0?.distance and recalculates the merchant when the route distance changes and also sets setMoneyRequestMerchant
    We can do something like this

        useEffect(() => {
            // Only run for distance requests (not manual distance, which uses customUnit.quantity)
            const isDistanceRequest = iouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE || iouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE_MAP;
            if (!isDistanceRequest || !transactionID || isEditing || !transaction) {
                return;
            }
    
            // Check if we have a route with distance
            const routeDistance = transaction?.routes?.route0?.distance;
            if (!routeDistance) {
                return;
            }
    
            // Get mileage rate info
            const policyCurrency = policy?.outputCurrency ?? getPersonalPolicy()?.outputCurrency ?? CONST.CURRENCY.USD;
            const mileageRates = DistanceRequestUtils.getMileageRates(policy);
            const defaultMileageRate = DistanceRequestUtils.getDefaultMileageRate(policy);
            const mileageRate: MileageRate | undefined = isCustomUnitRateIDForP2P(transaction)
                ? DistanceRequestUtils.getRateForP2P(policyCurrency, transaction)
                : // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
                  (customUnitRateID && mileageRates?.[customUnitRateID]) || defaultMileageRate;
    
            const {unit, rate} = mileageRate ?? {};
            const currency = mileageRate?.currency ?? policyCurrency;
            const hasRouteValue = hasRoute(transaction, true);
    
            // Recalculate merchant with the latest route distance
            const distanceMerchant = DistanceRequestUtils.getDistanceMerchant(hasRouteValue, routeDistance, unit, rate ?? 0, currency, translate, toLocaleDigit);
            setMoneyRequestMerchant(transactionID, distanceMerchant, true);
        }, [
            transaction?.routes?.route0?.distance,
            transactionID,
            isEditing,
            iouRequestType,
            transaction,
            policy,
            customUnitRateID,
            translate,
            toLocaleDigit,
        ]);
    
  10. dominictb commented on Dec 8, 2025

    @dominictb
    Contributor

    I agree that the root cause of this is ConvertTrackedExpenseToRequest does not handle distance updates. It also does not parse distance and rate based on merchant.

    To fix this issue, we should pass the new distance, rate and unit to BE as well

    I think this is the right solution we need. Need to pass separated distance, customUnitRateID, waypoints and isDistance: true params to ConvertTrackedExpenseToRequest endpoint just like what we do with TrackExpense endpoint .

    I'm keen on hearing an internal engineer opinion whether this is feasible.

    🎀 👀 🎀 C+ reviewed

  11. 51 remaining items

  12. melvin-bot commented on Mar 17, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  13. changed the title [-][$250] Track distance -In self DM, distance edited is not updated in 1:1 chat but updated amount is shown.[/-] [+][Awaiting Checklist] [$250] Track distance -In self DM, distance edited is not updated in 1:1 chat but updated amount is shown.[/+] on Mar 17, 2026
  14. melvin-bot commented on Mar 20, 2026

    @melvin-bot

    @garrettmknight Whoops! This issue is 2 days overdue. Let's get this updated quick!

  15. melvin-bot commented on Mar 20, 2026

    @melvin-bot

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

  16. garrettmknight commented on Mar 23, 2026

    @garrettmknight
    Contributor

    @mkhutornyi bump on the checklist, please.

  17. mkhutornyi commented on Mar 24, 2026

    @mkhutornyi
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: This didn't work from the beginning. The root cause was "missing feature" in both frontend and backend.

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion:

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue: https://github.com/Expensify/Expensify/issues/615757

    Regression Test Proposal

    Test:

    1. Open self DM
    2. Create a track manual distance
    3. Tap submit to someone
    4. Select a 1:1 user
    5. In confirm page, edit the distance
    6. Note amount and distance updated
    7. Tap create expense
    8. Open the expense
    9. Verify that In self DM, distance edited must be updated in 1:1 chat like updated amount is shown.

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-7279-a37c-6db6-0afa16aa5fd4
  18. mallenexpensify commented on Mar 24, 2026

    @mallenexpensify
    Contributor

    ^ Test case created

    Should be all good, closing

  19. quinthar commented on Mar 28, 2026

    @quinthar
    Contributor

    Approved $250 to @mkhutornyi

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething 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