Skip to content

[Payment due 2025-12-10] [$250] Manual Distance input placeholder defaults to Miles despite workspace preference set to Kilometers #75154

Closed

Description

@m-natarajan

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.2.58-2
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @brianlee-expensify
Slack conversation (hyperlinked to channel name): #Expensify bugs

Action Performed:

  1. Open a workspace where Distance preference = Kilometers
  2. Start the Track Distance Entry creation flow from global create
  3. Observe the default unit shown

Expected Result:

The distance unit should default to Kilometers, matching the workspace’s configured preference.

Actual Result:

The flow defaults to Miles, ignoring the workspace’s Kilometer setting.

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop
Platforms Tested: On which of our officially supported platforms was this issue tested:
  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Recording.1918.mp4
2025-11-13_14-42-45.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021993190186672235134
  • Upwork Job ID: 1993190186672235134
  • Last Price Increase: 2025-11-25
  • Automatic offers:
    • linhvovan29546 | Reviewer | 109604555
Issue OwnerCurrent Issue Owner: @brianlee-expensify

Activity

  1. added
    Bug
    on Nov 14, 2025
  2. melvin-bot commented on Nov 14, 2025

    @melvin-bot

    Triggered auto assignment to @greg-schroeder (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. ShridharGoel commented on Nov 14, 2025

    @ShridharGoel
    Contributor

    Proposal

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

    When a workspace is configured to prefer kilometers, creating a Track Distance expense from the global create menu still defaults the flow to miles.

    What is the root cause of that problem?

    The create flow only stores the selected distance rate ID with setCustomUnitRateID, which does not pull the full policy rate details or update the transaction's distanceUnit. As a result, the draft keeps the peer-to-peer fallback rate (mi) even when a workspace policy exists. This happens both when the flow auto-selects the workspace chat after tapping Track Distance and when participants are chosen later in the flow.

    • Distance tab auto-selection uses setCustomUnitRateID:

      const rateID = DistanceRequestUtils.getCustomUnitRateID({
      reportID: transactionReportID,
      isPolicyExpenseChat: true,
      policy: defaultExpensePolicy,
      lastSelectedDistanceRates,
      });
      setTransactionReport(transactionID, {reportID: transactionReportID}, true);
      setCustomUnitRateID(transactionID, rateID);
      setMoneyRequestParticipantsFromReport(transactionID, activePolicyExpenseChat).then(() => {
      Navigation.navigate(
      ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(
      CONST.IOU.ACTION.CREATE,
      iouType === CONST.IOU.TYPE.CREATE ? CONST.IOU.TYPE.SUBMIT : iouType,

    • Participant step also uses only the rate ID:

      }
      const firstParticipantReportID = val.at(0)?.reportID;
      const isPolicyExpenseChat = !!firstParticipant?.isPolicyExpenseChat;
      const policy = isPolicyExpenseChat && firstParticipant?.policyID ? allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${firstParticipant.policyID}`] : undefined;
      const isInvoice = iouType === CONST.IOU.TYPE.INVOICE && isInvoiceRoomWithID(firstParticipantReportID);
      numberOfParticipants.current = val.length;
      // Use transactions array if available, otherwise use initialTransactionID directly
      // This handles the case where initialTransaction hasn't loaded yet but we still need to set participants
      if (transactions.length > 0) {
      transactions.forEach((transaction) => {
      setMoneyRequestParticipants(transaction.transactionID, val);
      });
      } else {
      // Fallback to using initialTransactionID directly when transaction object isn't loaded yet
      setMoneyRequestParticipants(initialTransactionID, val);
      }
      if (!isMovingTransactionFromTrackExpense) {
      // If not moving the transaction from track expense, select the default rate automatically.
      // Otherwise, keep the original p2p rate and let the user manually change it to the one they want from the workspace.
      const rateID = DistanceRequestUtils.getCustomUnitRateID({reportID: firstParticipantReportID, isPolicyExpenseChat, policy, lastSelectedDistanceRates, localeCompare});
      if (transactions.length > 0) {
      transactions.forEach((transaction) => {
      setCustomUnitRateID(transaction.transactionID, rateID);
      });
      } else {
      // Fallback to using initialTransactionID directly
      setCustomUnitRateID(initialTransactionID, rateID);
      }
      }

    • The confirmation list defaults the rate ID without syncing the unit:

      const defaultRate = defaultMileageRate?.customUnitRateID;
      const lastSelectedRate = lastSelectedDistanceRates?.[policy.id] ?? defaultRate;
      const rateID = lastSelectedRate;
      if (!rateID) {
      return;
      }
      setCustomUnitRateID(transactionID, rateID);
      }, [defaultMileageRate, customUnitRateID, lastSelectedDistanceRates, policy?.id, transactionID, isDistanceRequest]);
      const mileageRate = DistanceRequestUtils.getRate({transaction, policy, policyDraft});
      const rate = mileageRate.rate;
      const prevRate = usePrevious(rate);
      const unit = mileageRate.unit;
      const prevUnit = usePrevious(unit);
      const currency = mileageRate.currency ?? CONST.CURRENCY.USD;

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

    Use the existing setMoneyRequestDistanceRate helper everywhere we select a rate so the rate ID, unit, and converted distance stay aligned with the chosen workspace policy.

    1. Distance (map + manual) tabs when chaining into a workspace:
    const rateID = DistanceRequestUtils.getCustomUnitRateID({...});
    setTransactionReport(transactionID, {reportID: transactionReportID}, true);
    setMoneyRequestDistanceRate(transactionID, rateID, defaultExpensePolicy, shouldUseTransactionDraft(action));

    This ensures the transaction draft immediately stores the workspace’s rate and unit along with any necessary distance conversion.

    1. Participants step when a policy chat is selected:
    const updateDistanceRate = (transactionID: string) => {
        if (policy) {
            setMoneyRequestDistanceRate(transactionID, rateID, policy, isTransactionDraft);
            return;
        }
        setCustomUnitRateID(transactionID, rateID);
    };

    We still fall back to setCustomUnitRateID for non-policy chats, but policy selections now hydrate the rate via the helper.

    1. Confirmation list defaulting and self-DM migrations:
    setMoneyRequestDistanceRate(transactionID, rateID, policy, isTransactionDraft);
    ...
    if (matchingRate?.customUnitRateID) {
        setMoneyRequestDistanceRate(transactionID, matchingRate.customUnitRateID, policy, isTransactionDraft);
        return;
    }
  4. Eskalifer1 commented on Nov 14, 2025

    @Eskalifer1
    Contributor

    Proposal

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

    Manual Distance Entry defaults to Miles despite workspace preference set to Kilometers

    What is the root cause of that problem?

    We always select unit based on current reportID here:

    const policy = usePolicy(report?.policyID);

    const unit = DistanceRequestUtils.getRate({transaction, policy}).unit;

    But when user starts flow creation fron the FAB we doesn’t have report, that means we doesnt have a policy, so we are defaulting to mi

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

    We can add a default value in the form of defaultExpensePolicy. If the user does not have a default workspace, then rely on the default value:

    policy: policy ?? defaultExpensePolicy ?? undefined

    const unit = DistanceRequestUtils.getRate({transaction, policy}).unit;

    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.

  5. changed the title [-]Manual Distance Entry defaults to Miles despite workspace preference set to Kilometers[/-] [+]Manual Distance input placeholder defaults to Miles despite workspace preference set to Kilometers[/+] on Nov 18, 2025
  6. brianlee-expensify commented on Nov 25, 2025

    @brianlee-expensify
    Contributor

    @greg-schroeder just wanted to bump this so we can get C+ review!

  7. added
    External
    on Nov 25, 2025
  8. changed the title [-]Manual Distance input placeholder defaults to Miles despite workspace preference set to Kilometers[/-] [+][$250] Manual Distance input placeholder defaults to Miles despite workspace preference set to Kilometers[/+] on Nov 25, 2025
  9. melvin-bot commented on Nov 25, 2025

    @melvin-bot
  10. added
    Help Wanted
    on Nov 25, 2025
  11. 10 remaining items

  12. melvin-bot commented on Nov 25, 2025

    @melvin-bot

    📣 @linhvovan29546 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

    Offer link
    Upwork job

  13. added
    Reviewing
    Weekly
    and removed
    Daily
    on Nov 26, 2025
  14. nkdengineer commented on Nov 26, 2025

    @nkdengineer
    Contributor

    @linhvovan29546 The PR is ready for review.

  15. brianlee-expensify commented on Dec 4, 2025

    @brianlee-expensify
    Contributor

    @linhvovan29546 just wanted to bump here in case this got lost on your radar!

  16. linhvovan29546 commented on Dec 5, 2025

    @linhvovan29546
    Contributor

    The PR was deployed to production on Dec 3, 2025. Could you please update the payment due date? I’ll complete the checklist shortly.

  17. linhvovan29546 commented on Dec 9, 2025

    @linhvovan29546
    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: https://github.com/Expensify/App/pull/69372/files#r2600877815

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

    Regression Test Proposal

    1. Open the default workspace and set the distance unit to kilometers
    2. Start the Track Distance Manual creation flow from the global create
    3. Verify that the unit placeholder is kilometers

    Do we agree 👍 or 👎

  18. changed the title [-][$250] Manual Distance input placeholder defaults to Miles despite workspace preference set to Kilometers[/-] [+][Payment due 2025-12-10] [$250] Manual Distance input placeholder defaults to Miles despite workspace preference set to Kilometers[/+] on Dec 12, 2025
  19. brianlee-expensify commented on Dec 12, 2025

    @brianlee-expensify
    Contributor

    assigning to myself since Greg is already out for the weekend

    updated GH title to Dec 10 payment date based on this deploy to prod

  20. brianlee-expensify commented on Dec 12, 2025

    @brianlee-expensify
    Contributor

    Payment Summary

    Contributor: @linhvovan29546 paid $250 via Upwork
    Contributor+: @nkdengineer due $250 via NewDot

  21. twisterdotcom commented on Dec 30, 2025

    @twisterdotcom
    Contributor

    @nkdengineer has submitted payment for this report on ND here.

    SO: https://stackoverflowteams.com/c/expensify/questions/7582

    Zapier Logs Run ID: 00040eee-6586-a60b-89a0-ac1ce876f794
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugExternalReviewingWeekly

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions