Skip to content

Copy UK fuel-band rates with their reclaimable fraction and check it for the lightning bolt - #104309

Draft
MelvinBot wants to merge 1 commit into
mainfrom
claude-ukFuelBandGovernmentRates
Draft

MelvinBot wants to merge 1 commit into
mainfrom
claude-ukFuelBandGovernmentRates

Conversation

@MelvinBot

Copy link
Copy Markdown
Contributor

Explanation of Change

The UK publishes fuel-band mileage rates alongside its standard (AMAP) rate. The server will copy the bands, with their VAT-reclaimable fraction, only to workspaces that track tax and have distance tax on, and AMAP to every other workspace. The App's optimistic copy didn't know about bands, so it would have added AMAP plus every band, without the fraction. The lightning bolt also ignored the reclaimable amount, so an edited band still looked auto-generated.

  • Types: GovernmentMileageRate and GovernmentRateSnapshot get an optional taxClaimablePercentage.
  • Picking rates: buildOnyxDataForGovernmentRateAutoUpdate uses isTaxTrackingEnabled(true, policy, true) as shouldUseFuelBandRates. For GB rates only, it copies the bands when that is true and the standard rate otherwise. Other countries are unaffected.
  • Series: the new getGovernmentRateSeries strips the trailing _<startDate> with lastIndexOf('_'), so band IDs like GB_PETROL_UP_TO_1400_2026-06-01 (whose band names contain _) resolve to GB_PETROL_UP_TO_1400.
  • New fields on copied rates: taxClaimablePercentage goes on the rate and its snapshot when the reference rate has one. enabled comes from the previous rate in the same series, including rates copied earlier in the same request, and falls back to the reference rate's value. taxRateExternalID is left to the server response.
  • Signature: buildOnyxDataForGovernmentRateAutoUpdate and setWorkspaceDistanceAutoUpdate now take policy instead of policyID + customUnit, which are derived inside. All callers already had policy.
  • Lightning bolt: when the snapshot has a reclaimable fraction, isGovernmentRateUnmodified also compares the reclaimable amount at the 4-decimal precision the edit page shows. Re-entering the shown value therefore brings the bolt back. Snapshots without a fraction, such as US/EUR rates, ignore it as before. The edit page now uses the same getTaxClaimableDisplayAmount helper, and its useCallback was removed so React Compiler can still compile the component.

Note: the enabled inheritance applies to every country's copied rates, matching the server's shared copy. A GBP currency change without a country still copies nothing optimistically; the server copies the bands and its response adds them.

AI tests run by MelvinBot: npm run typecheck, npm run lint-changed, npm run fmt, npm run spell-changed, react-compiler-compliance-check on the changed pages, and Jest for DistanceRateTest, PolicyDistanceRatesUtilsTest, PolicyTest, PolicyUtilsTest, WorkspaceOverviewCurrencyPageTest, WorkspaceUpgradeTest, IOURequestStepDistanceRateTest and the distance-rate hook tests (all passed). The full Jest suite and the Storybook smoke test were not run locally.

Fixed Issues

$ #104135
PROPOSAL: #104135 (comment)

Tests

// TODO: The human co-author must fill out the tests you ran before marking this PR as "ready for review"
// Please describe what tests you performed that validates your changed worked.

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

// TODO: The human co-author must fill out the QA tests you ran before marking this PR as "ready for review".
// Please describe what QA needs to do to validate your changes and what areas do they need to test for regressions.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@MelvinBot
MelvinBot requested a review from a team October 18, 2026 10:44
@melvin-bot melvin-bot Bot added Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web labels Oct 18, 2026
@MelvinBot

Copy link
Copy Markdown
Contributor Author

I created this PR from an upstream branch since I don't have push access to your fork.

To take ownership of this branch and be able to push updates, run:

git remote add upstream https://github.com/Expensify/App.git
git fetch upstream claude-ukFuelBandGovernmentRates
git checkout -b claude-ukFuelBandGovernmentRates upstream/claude-ukFuelBandGovernmentRates
git push -u origin claude-ukFuelBandGovernmentRates

Then you can close this PR and open a new one from your fork.

@codecov

codecov Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/CONST/index.ts 95.90% <ø> (ø)
src/libs/actions/Policy/DistanceRate.ts 66.01% <ø> (ø)
src/libs/actions/Policy/Policy.ts 71.94% <ø> (ø)
src/libs/PolicyDistanceRatesUtils.ts 69.36% <97.61%> (+5.40%) ⬆️
.../distanceRates/PolicyDistanceRatesSettingsPage.tsx 0.00% <0.00%> (ø)
...es/PolicyDistanceRateGovernmentRateCountryPage.tsx 0.00% <0.00%> (ø)
...Rates/PolicyDistanceRateTaxReclaimableEditPage.tsx 0.00% <0.00%> (ø)
...c/pages/workspace/upgrade/WorkspaceUpgradePage.tsx 58.66% <0.00%> (+0.38%) ⬆️
... and 11 files with indirect coverage changes

@MelvinBot

MelvinBot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Web test steps verification results: ⚠️ partial

The PR's only documented test step is "Verify that no errors appear in the JS console", so I ran it across the changed distance-rate flows on a GBP Control workspace: no errors or broken UI appeared. Two gaps: this dev backend returned only the standard GB (AMAP) rate, so fuel-band rows never appeared, and the web tool cannot read raw console output, so the console check relies on no visible errors.
Bolt retained after reverting to 0

Step Status
Turning on government rate auto-update for a GBP workspace adds government rates with the lightning boltAuto-update on, currency set to GBP. The list showed 4/6/11 - 4/5/26 Great Britain (expired, £0.45/mile) and 4/6/26 Great Britain (active, £0.55/mile), both marked auto-generated with the bolt.
GB rates with lightning bolt
Auto-update government rate on
✅
With Taxes and distance Track tax on, regenerating GB rates updates the list without errors (AMAP vs fuel bands)Toggling auto-update off and on left existing rates unchanged, as the UI states. After deleting the GB rates and switching USD→GBP with tax tracking on, the new rates were still AMAP (£0.45 / £0.55), with no reclaimable amount prefilled. The dev backend appears to have no GB fuel-band reference rates, so the fuel-band path could not be seen in the UI.
Auto-update re-enabled with Track tax on
Regenerated GB rates are AMAP
⚠️
Editing a government rate's tax reclaimable amount and restoring it works without errorsOn the active GB rate, Tax Rate 1 (5%) was set and the reclaimable amount was changed from £0 to £0.10, then back to 0. The bolt stayed both times. This is expected for an AMAP snapshot with no percentage, which skips the new reclaimable check. Validation correctly rejected £20 ("The reclaimable portion must be less than the distance rate amount").
Tax reclaimable set to 0.10
Bolt retained after edit
Bolt retained after reverting to 0
✅
Verify that no errors appear in the JS consoleNo error toasts, crash screens, blank panels, or broken layouts appeared during the session. The web device tool has no console-capture command, so raw console output was not read.
⚠️

view run · view recording

@MelvinBot

MelvinBot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Android test steps verification results: ✅ pass

On Android, GB government rates were auto-generated with the lightning bolt, and turning on Track tax and regenerating the rates caused no errors. The bolt stayed through every Tax reclaimable edit, and no JS errors or redboxes appeared. As on Web, only the standard GB (AMAP) rates appeared, never fuel bands, and logs weren't streamed, so the console check relies on no visible errors.
Bolt kept after reverting to 0.11

Step Status
Turning on Auto-update government rate for a GBP workspace adds GB rates with the lightning boltTwo GB rates were created: 4/6/11 - 4/5/26 Great Britain (£0.45/mile, expired) and 4/6/26 Great Britain (£0.55/mile, active). Both were marked "This rate is auto-generated" and showed the bolt.
GB AMAP rates with lightning bolt
✅
With Taxes and Track tax on, toggling auto-update and regenerating GB rates updates the list without errorsToggling auto-update off and on left existing rates unchanged, as the UI states. After deleting the GB rates and switching GBP → USD → GBP, the same standard AMAP rates (£0.45 / £0.55) came back with the bolt. No fuel-band rates appeared, even with Taxes and Track tax on.
Track tax enabled
GB rates regenerated, still AMAP
✅
Editing and restoring the Tax reclaimable amount on an auto-generated GB rate works without errorsSetting Tax Rate 1 (5%) showed "Tax reclaimable on". Saving £0.11, then £0.22, then £0.11 again kept the bolt each time. This is expected for an AMAP snapshot with no reclaimable percentage, which skips the new check.
Tax rate set, Tax reclaimable on shown
Bolt kept after saving 0.11
Bolt kept after changing to 0.22
Bolt kept after reverting to 0.11
✅
Verify that no errors appear in the JS consoleNo redboxes, crashes, or error banners appeared during onboarding, workspace setup, currency changes, toggles, rate regeneration, or tax edits. An unrelated "Add payment card" billing reminder appeared and was closed. Log streaming was off, so logcat wasn't searched.
✅

view run · view recording

This branch has not been deployed

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

Labels

Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants