Skip to content

[Due for payment 2025-11-26] Default distance rate is not selected when creating distance expense #72328

Closed

Description

@nlemma

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.29-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: #71529
Email or phone of affected tester (no customers): expensify416+da2@gmail.com
Issue reported by: Applause Internal Team
Device used: macOS chrome 14.2, mWeb, Android, Desktop
App Component: Money Requests

Action Performed:

  1. Create a new workspace
  2. Enable Distance Rates
  3. Add two new rates
  4. Rename the two new rates to A, and B
  5. Go to workspace chat
  6. Click + > Track distance > select start and end way points > Next
  7. Click on Rate

Expected Result:

The default rate should be preselected

Actual Result:

Rate "A" is preselected

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

Bug6970734_1760100254704.Screen_Recording_2025-10-10_at_3.37.21_in_the_afternoon.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @CortneyOfstad / @stephanieelliott

Activity

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

    @melvin-bot

    Triggered auto assignment to @stephanieelliott (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. melvin-bot commented on Oct 10, 2025

    @melvin-bot

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

  4. melvin-bot commented on Oct 10, 2025

    @melvin-bot

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

  5. github-actions commented on Oct 10, 2025

    @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. nyomanjyotisa commented on Oct 10, 2025

    @nyomanjyotisa
    Member

    This was coming from my PR

    Currently, on getDefaultMileageRate, we get the first item in the mileageRates as the default rate. In this case, since we sort the mileageRates alphabetically, the rate named "A" will be the first one and preselected

    const distanceRate = mileageRates.at(0) ?? ({} as MileageRate);

    As far as I know, we don't have any param to get the default distance rate value of a workspace. This is what mileageRates return before we clear cache and restart

    mileageRates before clearing cache
    [
        {
            "rate": 70,
            "currency": "IDR",
            "unit": "mi",
            "name": "Default Rate",
            "customUnitRateID": "5CE340F95B19A",
            "enabled": true
        },
        {
            "rate": 100,
            "currency": "IDR",
            "unit": "mi",
            "name": "New Rate",
            "customUnitRateID": "4CBA6738CF3B4",
            "enabled": true
        },
        {
            "rate": 200,
            "currency": "IDR",
            "unit": "mi",
            "name": "A",
            "customUnitRateID": "A20E6912BD6B9",
            "enabled": true
        },
        {
            "rate": 300,
            "currency": "IDR",
            "unit": "mi",
            "name": "B",
            "customUnitRateID": "4B1173A5E7141",
            "enabled": true
        }
    ]
    

    Then when we sort it alphabetically based on name, it would return this

    mileageRates after sort
    [
        {
            "rate": 200,
            "currency": "IDR",
            "unit": "mi",
            "name": "A",
            "customUnitRateID": "A20E6912BD6B9",
            "enabled": true
        },
        {
            "rate": 300,
            "currency": "IDR",
            "unit": "mi",
            "name": "B",
            "customUnitRateID": "4B1173A5E7141",
            "enabled": true
        },
        {
            "rate": 70,
            "currency": "IDR",
            "unit": "mi",
            "name": "Default Rate",
            "customUnitRateID": "5CE340F95B19A",
            "enabled": true
        },
        {
            "rate": 100,
            "currency": "IDR",
            "unit": "mi",
            "name": "New Rate",
            "customUnitRateID": "4CBA6738CF3B4",
            "enabled": true
        }
    ]
    

    But when we clear the cache and restart, mileageRates get sorted 'randomly'

    mileageRates after clearing cache
    [
        {
            "rate": 300,
            "currency": "IDR",
            "unit": "mi",
            "name": "B",
            "customUnitRateID": "4B1173A5E7141",
            "enabled": true
        },
        {
            "rate": 100,
            "currency": "IDR",
            "unit": "mi",
            "name": "New Rate",
            "customUnitRateID": "4CBA6738CF3B4",
            "enabled": true
        },
        {
            "rate": 70,
            "currency": "IDR",
            "unit": "mi",
            "name": "Default Rate",
            "customUnitRateID": "5CE340F95B19A",
            "enabled": true
        },
        {
            "rate": 200,
            "currency": "IDR",
            "unit": "mi",
            "name": "A",
            "customUnitRateID": "A20E6912BD6B9",
            "enabled": true
        }
    ]
    

    If we don't sort the getDefaultMileageRate, we will randomly preselect any rates that come first on mileageRates after we clearing the cache

    497648095-7d273726-76eb-454c-aced-086bd223dff2.mp4

    My PR prevents this by sorting the rates in getDefaultMileageRate, but it will always preselect the first rate displayed. Since we don't have any param to define the default rate, I think it makes sense for the preselected rate to match the first rate in the UI list

    However, we could implement a workaround, like searching for a rate with a specific name (like "Default Rate") before falling back to the first rate in the sorted list

        const defaultRate = mileageRates.find((rate) => rate.name?.toLocaleLowerCase() === CONST.CUSTOM_UNITS.DEFAULT_RATE.toLocaleLowerCase());
        const distanceRate = defaultRate ?? mileageRates.at(0) ?? ({} as MileageRate);

    But again, this is just a workaround and not the best solution

    cc @ishpaul777

  7. francoisl commented on Oct 10, 2025

    @francoisl
    Contributor

    As far as I know, we don't have any param to get the default distance rate value of a workspace.

    That's correct, the first enabled rate in the rates JSON array is considered the default rate.

    But when we clear the cache and restart, mileageRates get sorted 'randomly'

    I think this is the real issue. Do you know what causes this random sorting? Is the list of rates returned in that order from the backend? It's stored as a JSON array in the policy object in the backend, so it should preserve its order.

    However, we could implement a workaround, like searching for a rate with a specific name (like "Default Rate") before falling back to the first rate in the sorted list

    Looks like we used similar logic in the backend until recently, but removed all that logic, so I'd recommend not going with that solution (cc @MonilBhavsar in case you have an opinion or suggestion here, cc #47801).

    For now I'll demote but @nyomanjyotisa I'm thinking #71529 wasn't necessarily the proper solution to the issue, and we should instead figure out what's causing the unexpected sorting when we clear the cache.

  8. 51 remaining items

  9. melvin-bot commented on Nov 19, 2025

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  10. melvin-bot commented on Nov 19, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.60-2 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2025-11-26. 🎊

  11. melvin-bot commented on Nov 19, 2025

    @melvin-bot

    @francoisl @CortneyOfstad / @stephanieelliott The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  12. suneox commented on Nov 26, 2025

    @suneox
    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.

      Fix: Order of distance rates on confirm page changes after reset app #71529 (comment)

    • [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.

      N/A

    • [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.

      N/A: This isn’t an impactful bug, as it only changes the default selected distance rates.

  13. suneox commented on Nov 26, 2025

    @suneox
    Contributor

    @CortneyOfstad Could you please assign me to this issue since I’ve reviewed this PR?

  14. CortneyOfstad commented on Dec 1, 2025

    @CortneyOfstad
    Contributor

    Thanks for your patience @suneox! With the Thanksgiving holiday, and confirmation needed on payment amount, this got a bit delayed 👍

  15. CortneyOfstad commented on Dec 1, 2025

    @CortneyOfstad
    Contributor

    Payment Summary

    @suneox — to be paid $250 via NewDot

    Regression Test

    N/A: This isn’t an impactful bug, as it only changes the default selected distance rates.

  16. moved this from MEDIUM or LOW to Done in [#whatsnext] #migrateon Dec 1, 2025
  17. garrettmknight commented on Dec 18, 2025

    @garrettmknight
    Contributor

    $250 approved for @suneox

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.DailyKSv2Engineering

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions