Skip to content

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

Open
MelvinBot wants to merge 3 commits into
mainfrom
claude-ukFuelBandGovernmentRates
Open

MelvinBot wants to merge 3 commits into
mainfrom
claude-ukFuelBandGovernmentRates

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Oct 18, 2026 •

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

Standard (AMAP) rates — workspace without distance tax

  1. Create a Control workspace and set its default currency to GBP.
  2. Go to Workspace > More features and turn on Distance rates.
  3. Go to Distance rates > Settings and turn on Auto-update government rate.
  4. Go back to Distance rates. Verify the standard Great Britain rates are added (for example £0.45/mile and £0.55/mile), each with the lightning bolt.
  5. Verify no fuel-band rates are added.

Fuel-band rates — workspace with distance tax
These steps need the server to publish GB fuel-band reference rates. Until it does, only the standard rates appear.
6. Create another Control workspace and set its default currency to GBP.
7. Go to Workspace > More features and turn on Distance rates and Taxes.
8. Go to Distance rates > Settings and turn on Track tax.
9. In the same Settings page, turn on Auto-update government rate.
10. Go back to Distance rates. Verify the Great Britain fuel-band rates are added (one rate per fuel type / engine size band), each with the lightning bolt.
11. Verify the standard Great Britain (AMAP) rate is not added.

Lightning bolt and tax reclaimable
12. Open one of the fuel-band rates and note the Tax reclaimable on amount.
13. Change the Tax reclaimable on amount to a different value and save.
14. Verify the lightning bolt no longer shows for that rate.
15. Open the same rate, set Tax reclaimable on back to the amount from step 12, and save.
16. Verify the lightning bolt shows again for that rate.

Turning on tax after auto-update
17. On the workspace from step 1, go to More features and turn on Taxes. Then go to Distance rates > Settings and turn on Track tax.
18. Go back to Distance rates. Verify the existing Great Britain (AMAP) rates are unchanged and still show the lightning bolt. Adding fuel-band rates at this point is out of scope here and tracked in [HOLD #104135] Optimistic UK fuel-band rates when turning on tax.
19. Open one of these AMAP rates, set a tax rate, change its Tax reclaimable on amount, and save. Verify the lightning bolt still shows (AMAP rates ignore the reclaimable amount).

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

Standard (AMAP) rates — workspace without distance tax

  1. Create a Control workspace and set its default currency to GBP.
  2. Go to Workspace > More features and turn on Distance rates.
  3. Go to Distance rates > Settings and turn on Auto-update government rate.
  4. Go back to Distance rates. Verify the standard Great Britain rates are added, each with the lightning bolt.
  5. Verify no fuel-band rates are added.

Fuel-band rates — workspace with distance tax
These steps need the server to publish GB fuel-band reference rates. Until it does, only the standard rates appear.
6. Create another Control workspace and set its default currency to GBP.
7. Go to Workspace > More features and turn on Distance rates and Taxes.
8. Go to Distance rates > Settings and turn on Track tax.
9. In the same Settings page, turn on Auto-update government rate.
10. Go back to Distance rates. Verify the Great Britain fuel-band rates are added (one rate per fuel type / engine size band), each with the lightning bolt.
11. Verify the standard Great Britain (AMAP) rate is not added.

Lightning bolt and tax reclaimable
12. Open one of the fuel-band rates and note the Tax reclaimable on amount.
13. Change the Tax reclaimable on amount to a different value and save.
14. Verify the lightning bolt no longer shows for that rate.
15. Open the same rate, set Tax reclaimable on back to the amount from step 12, and save.
16. Verify the lightning bolt shows again for that rate.

Turning on tax after auto-update
17. On the workspace from step 1, go to More features and turn on Taxes. Then go to Distance rates > Settings and turn on Track tax.
18. Go back to Distance rates. Verify the existing Great Britain (AMAP) rates are unchanged and still show the lightning bolt.
19. Open one of these AMAP rates, set a tax rate, change its Tax reclaimable on amount, and save. Verify the lightning bolt still shows.

Regression — other countries
20. Create a Control workspace in USD, turn on Distance rates, and turn on Auto-update government rate.
21. Verify the United States government rates are added with the lightning bolt, as before.

  • 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 70.83% <97.61%> (+4.99%) ⬆️
.../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 10 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

@thelullabyy

Copy link
Copy Markdown
Contributor

@MelvinBot Please replace all [ ] by [x] in PR description. Also fill out testing steps for Tests and QA Tests. Then open PR for review

@MelvinBot
MelvinBot marked this pull request as ready for review October 19, 2026 16:09
@MelvinBot
MelvinBot requested a review from a team as a code owner October 19, 2026 16:09
@melvin-bot
melvin-bot Bot requested review from thelullabyy and removed request for a team October 19, 2026 16:09
@melvin-bot

melvin-bot Bot commented Oct 19, 2026

Copy link
Copy Markdown

@thelullabyy Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Done. I updated the PR description and marked the PR ready for review.

  • Checkboxes: all 38 are now [x]; none remain unchecked.
  • Tests: added numbered steps for three flows: standard (AMAP) rates on a GBP workspace without distance tax, fuel-band rates with Taxes and Track tax on, and the lightning bolt hiding and returning when you change and restore Tax reclaimable on. I removed the TODO placeholders.
  • QA Steps: the same flows for staging, plus a USD workspace check that other countries are unaffected.

Earlier dev-environment runs showed only AMAP rates, so you may need staging to see the fuel-band rows. I left Offline tests and Screenshots/Videos empty for you to fill in.


view run

@melvin-bot
melvin-bot Bot requested review from garrettmknight and removed request for a team October 19, 2026 16:10
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T16:15:04.331228Z 7c90d4d Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@thelullabyy

thelullabyy commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • 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 verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-10-20.at.00.13.18.mov
Screen.Recording.2026-10-20.at.00.16.20.mov

@thelullabyy thelullabyy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the logic looks good to me. A few comments inline.

One small thing in the PR description: Tests step 17 says to set a tax rate on a Great Britain rate on the AMAP workspace from step 1, but that workspace has Taxes / Track tax off, so the tax rate and Tax reclaimable on fields aren't available there. Can you update that step (e.g. turn on Taxes but leave Track tax off, or remove it)?


if (shouldAutoUpdateGovernmentDistanceRates && customUnit) {
const copiedSourceRateIDs = new Set(Object.values(customUnit.rates ?? {}).map((rate) => rate.attributes?.governmentRate?.sourceRateID));
const shouldUseFuelBandRates = isTaxTrackingEnabled(true, policy, true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only evaluated when auto-update is turned on. What happens if a GBP workspace already has auto-update on with the AMAP rates and the admin then turns on Track tax (or turns it off on a workspace that has the bands)? enableDistanceRequestTax doesn't touch the rates, so optimistically nothing changes.

Does the server swap AMAP <-> fuel bands when distance tax is toggled? If it does, we should mirror that optimistically in enableDistanceRequestTax (and the policy Taxes toggle). If it doesn't, the workspace stays on AMAP after enabling tax, which seems to go against the goal here. Either way, can we add a test step covering this order (auto-update first, Track tax second)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. The server does handle this order, but this PR doesn't mirror it optimistically, on purpose.

  • Turning tax on: when turning on distance tax (or turning tax tracking back on) makes a GBP auto-update workspace eligible, the server adds the missing fuel-band rates. It doesn't remove the existing AMAP rates. Mirroring that in enableDistanceRequestTax and enablePolicyTaxes is the follow-up [HOLD #104135] Optimistic UK fuel-band rates when turning on tax, which is on hold for this PR and reuses buildOnyxDataForGovernmentRateAutoUpdate.
  • Turning tax off: nothing is swapped. Existing fuel-band rates stay, the same way auto-update never modifies existing rates.

I added a "Turning on tax after auto-update" block to Tests and QA (steps 17–19): on the AMAP workspace, turn on Taxes and Track tax, then check the AMAP rates are unchanged and keep the bolt. That also fixes the old step 17, which set a tax rate while tax was off.


view run

Comment thread src/libs/PolicyDistanceRatesUtils.ts Outdated

/** Whether a government rate is a UK fuel band, whose series carries the band after the country code. */
function isFuelBandGovernmentRate(sourceRateID: string): boolean {
return getGovernmentRateSeries(sourceRateID) !== sourceRateID.split('_').at(0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: this computes the series and splits the ID again just to check whether there is a segment between the country and the date. Could be simpler and easier to read:

return sourceRateID.split('_').length > 2;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in edc5108: isFuelBandGovernmentRate now returns sourceRateID.split('_').length > 2. Results don't change: GB_2026-04-06 has 2 parts and band IDs have more.


view run

@thelullabyy

Copy link
Copy Markdown
Contributor

@MelvinBot Please update your PR based on above reviews

@MelvinBot
MelvinBot requested a review from a team as a code owner October 19, 2026 16:35
@melvin-bot
melvin-bot Bot requested review from neil-marcellini and thelullabyy and removed request for a team October 19, 2026 16:35
@melvin-bot

melvin-bot Bot commented Oct 19, 2026

Copy link
Copy Markdown

@thelullabyy @neil-marcellini One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@MelvinBot

Copy link
Copy Markdown
Contributor Author

I updated the PR based on your review.

  • Simplified fuel-band check: I pushed edc5108. isFuelBandGovernmentRate now uses sourceRateID.split('_').length > 2.
  • Turning tax on after auto-update: this PR leaves the existing AMAP rates unchanged. The server adds the missing fuel-band rates. The optimistic copy is tracked in [HOLD #104135] Optimistic UK fuel-band rates when turning on tax. I replied in the thread with details.
  • Test steps: I replaced the old step 17. Steps 17–19 now turn on Taxes and Track tax on the AMAP workspace, then check that the rates are unchanged and keep the lightning bolt. Tests and QA both include this. I also noted that the fuel-band steps need the server to publish GB fuel-band reference rates.

Typecheck, ESLint on the changed file, and 309 Jest tests in PolicyDistanceRatesUtilsTest, DistanceRateTest and PolicyTest pass.


view run

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The failing check is unrelated to this PR. No code fix is needed. Please rerun the failed Bun tests job.

Analysis: One CI tooling test failed: CIGitLogic > Deploying a PR, then CPing a revert, then adding the same code back again.... It crashed in its own temp-directory cleanup, before any assertion ran. fs.existsSync saw /tmp/ci-git-logic-*/checkout, but fs.rmSync then threw ENOENT: no such file or directory. That is a filesystem race in the test harness at tests/tooling/CIGitLogic.test.ts:224.

Evidence: This PR changes only distance-rate code and its tests (src/libs/PolicyDistanceRatesUtils.ts, src/libs/actions/Policy/*, src/pages/workspace/distanceRates/*, and related tests). None of these touch tests/tooling/ or the CI git logic. The other 615 Bun tests passed.

The other two failures, checklist and Check independent approval, are review-process checks. They clear once the checklist is completed and the PR is approved.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

I merged main into this branch (c214308) to clear both failing checks. CI is re-running on the new commit.

  • ESLint check: it failed on src/libs/Navigation/types.ts:1 with Unused eslint-disable directive ... 'max-lines'. This PR doesn't touch that file. main itself was broken when CI ran. [No QA] Split SettingsNavigatorParamList out of Navigation/types.ts to fix max-lines lint fixed it 13 minutes later. The branch now has that fix.
  • Bun tests: one flaky tooling test (CIGitLogic) crashed while cleaning up its temp folder (ENOENT). This is unrelated to this PR, and the new CI run retries it.

checklist and Check independent approval clear after review.

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