Skip to content

[$175] Distance rates: show amounts with 2 decimals unless more were entered #106594

Open

Description

@neil-marcellini

(Neil's AI agent)

Follow-up to Allow inline editing of distance tax reclaimable amounts, from this review thread.

Problem

Distance rate amount editors always show 4 decimals. If an admin enters a rate of 0.1, the table shows $0.10, but editing it shows 0.1000. Three extra zeros look odd on a money amount.

The padding comes from .toFixed(CONST.MAX_TAX_RATE_DECIMAL_PLACES) in:

Solution

Show distance rate amounts with 2 decimals, and only show more when the admin actually entered more (up to 4):

Entered Shown
0.1 0.10
0.123 0.123
0.1234 0.1234

Apply this to all four editors together so Rate and Tax reclaimable stay consistent.

cc @Expensify/design for input, especially on whether the table should also show a rate like 0.1234 in full (it currently rounds to $0.12).

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

Activity

  1. dubielzyk-expensify commented on Nov 11, 2026

    @dubielzyk-expensify
    Contributor

    Sounds fine to me. I feel like I remember us reducing it to two for a reason. I think it makes sense to respect it if an admin has entered more though. I'd think that we should show 4 in the table for all if we show it for one, otherwise I think one number will just look way bigger than the others. No strong feelings here though

  2. shawnborton commented on Nov 11, 2026

    @shawnborton
    Contributor

    Hmm I do remember us increasing the amount of decimal places for the total distance traveled, but I don't recall any changes to the rates.

    I think it's actually common to have three decimal place rates (not sure about four) so I think we need to keep that ability. I agree that whatever the user enters is something we should show in the table (no rounding).

  3. trjExpensify commented on Nov 11, 2026

    @trjExpensify
    Contributor

    Yeah, I seem to recall the IRS rate being three decimals a few years ago - and also some customers using up to 4 decimals for their rates in some territories so we increased what was allowed years ago. Whatever amount of decimals we supported historically in Classic is what we should support in NewDot. I agree with showing what was entered. 👍

  4. dannymcclain commented on Nov 11, 2026

    @dannymcclain
    Contributor

    I'm aligned as well. Fine with the change and I agree we should show what they entered in the table.

    I'd think that we should show 4 in the table for all if we show it for one

    I disagree here though if I'm understanding your comment properly. I think we should just display the rate in the table exactly as they entered it (i.e. $0.20, $0.25, $0.2897)

  5. Krishna2323 commented on Nov 12, 2026

    @Krishna2323
    Contributor

    @MelvinBot post a proposal

  6. MelvinBot commented on Nov 12, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    All four editors initialize amounts using toFixed(4), which pads values such as 0.1 to 0.1000. The four-decimal input limit is correct; the unnecessary padding comes from formatting the initial value.

    Code evidence

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

    1. Add a shared distance-amount formatter that preserves existing four-decimal rounding, then removes trailing zeros only beyond two decimal places:
      • 0.1 → 0.10
      • 0.123 → 0.123
      • 0.1234 → 0.1234
    2. Use it for both Rate editors and the shared Tax reclaimable helper, covering all four editors. Keep four-decimal entry support, localization, validation, and stored values unchanged.
    3. Normalize both sides of the inline Tax reclaimable unchanged-value comparison so saving 0.10 instead of 0.1000 does not trigger an unnecessary update.
    4. Add regression tests covering all four editors, mixed-precision table rows, save/reopen, unchanged submissions, blank reclaimable values, and government-rate matching.

    Table clarification: In the current checkout, both table columns already support two to four decimal places independently per value. Preserve that behavior and add regression coverage rather than changing global currency formatting.

    Compatibility checks

    These findings are source-verified; browser behavior has not been tested.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/106594) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.


    view run

  7. Krishna2323 commented on Nov 12, 2026

    @Krishna2323
    Contributor

    @MelvinBot implement this with these refinements:

    1. Don't add a new formatter. getRateDisplayValue in src/libs/PolicyUtils/customUnits.ts already does the 2–4 decimal "OD Behavior". Extract its withDecimals fraction-digit logic into a helper without the locale separator step, reuse it from getRateDisplayValue, both Rate editors (WorkspaceDistanceRateValueCell, PolicyDistanceRateEditPage), and getTaxClaimableDisplayAmount.
    2. Normalize every unchanged-value check, not only the inline tax one: PolicyDistanceRateEditPage and PolicyDistanceRateTaxReclaimableEditPage compare raw strings with ===, so typing 0.1 when 0.10 is shown resends the same value. Compare numerically at 4 decimals in all four places.
    3. Keep tests at unit level: the new helper, both InlineEdit unchanged checks, and isGovernmentRateUnmodified.
  8. MelvinBot commented on Nov 12, 2026

    @MelvinBot
    Contributor

    Created draft PR: Show distance rate editor amounts with meaningful decimal precision, assigned to Krishna2323.

    Implemented all three refinements: reused the existing formatting logic, normalized all four unchanged-value checks, and added unit-level coverage.

    Passed: 902 relevant tests, lint, app/test type checks, spelling, component compiler checks, and Storybook smoke test.

    Full-suite timeouts and formatter-check limitations are documented in the PR.


    view run

  9. changed the title [-]Distance rates: show amounts with 2 decimals unless more were entered[/-] [+][$175] Distance rates: show amounts with 2 decimals unless more were entered[/+] on Nov 13, 2026
  10. melvin-bot commented on Nov 13, 2026

    @melvin-bot
  11. debarkamondal commented on Nov 15, 2026

    @debarkamondal

    @Krishna2323 I came to this Issue from Upwork. I can see that a PR has been merged. Is the issue solved or would you like me create a proposal?

    Upwork Profile: https://www.upwork.com/freelancers/~01c957006a1e6583da?mp_source=share

  12. melvin-bot commented on Nov 15, 2026

    @melvin-bot

    📣 @debarkamondal! 📣
    Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
    Please follow these steps:

    1. Make sure you've read and understood the contributing guidelines.
    2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
    3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
    4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
      Screen Shot 2022-11-16 at 4 42 54 PM
      Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
    
  13. debarkamondal commented on Nov 15, 2026

    @debarkamondal

    Contributor details
    Your Expensify account email: debarkamondal@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~01c957006a1e6583da

  14. melvin-bot commented on Nov 15, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  15. pinned and unpinned a comment on Nov 15, 2026
  16. Krishna2323 commented on Nov 15, 2026

    @Krishna2323
    Contributor

    @debarkamondal This one is resolved. If you're interested in contributing to Expensify, you can start by going through the contributing guidelines. Thanks!

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions