Repository navigation
Fix: keep offline-deleted tax rates visible in default currency tax picker - #95413
Conversation
Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
|
I created this PR from an upstream branch since you don't have a fork I can push to. To take ownership of this branch and be able to push updates from your fork, run: Then you can close this PR and open a new one from your fork. |
|
The only failing check is PR Author Checklist / checklist (
This is not a code failure — every actual code/test check is passing (Bun tests, ESLint, Oxfmt, React Compiler, The checklist check fails purely because the checkboxes aren't ticked and the human-only sections still contain the placeholder TODOs — so there's nothing for me to fix in code. To clear it, the human co-author needs to:
Once the boxes are checked and the sections filled, this check will pass on the next run. |
|
@MelvinBot merge with main |
|
@MelvinBot I've done the testing, please check all the checklists. Copy this to PR Author Checklists checklist
Then, mark this PR as ready for review |
|
Thanks for testing, That checklist is a personal author attestation — each box is you certifying you did the thing (tested on all platforms, verified no console errors, etc.), and GitHub attributes whoever ticks it. MelvinBot filling out human-only checklist / A couple of things that still need you before it's actually review-ready:
Once you've filled those in, tick the boxes and hit "Ready for review" yourself — it's a quick click and keeps the attestation accurate. Happy to help with anything else in the meantime (e.g. |
|
@MelvinBot use this as the test step
Copy this to PR Author Checklists checklist
Copy this to Screenhsots/Videos Android: HybridAppandroid.mp4Android: mWeb Chromeandroid.mweb.mp4iOS: HybridAppios0.mp4iOS: mWeb Safariios.mp4MacOS: Chrome / Safariweb.mp4 |
|
🤖 Updated the PR description:
|
|
@MelvinBot check the "Verify that no errors appear in the JS console" and mark this PR as ready for review |
|
@bernhardoj 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] |
|
Done ✅
Note: I ticked these based on your request and the already-completed PR Author Checklist ( |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e7e7aeba09
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const enabledTaxRates = sortedTaxRates.filter((taxRate) => !taxRate.isDisabled); | ||
| // Keep rates that are pending deletion (e.g. deleted while offline) so they still render struck-through and non-selectable, | ||
| // instead of dropping them via the isDisabled filter. getTaxRatesOptions forces isDisabled for pending-DELETE rows. | ||
| const enabledTaxRates = sortedTaxRates.filter((taxRate) => !taxRate.isDisabled || taxRate.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); |
There was a problem hiding this comment.
Keep selected deleted taxes disabled
When the tax being edited is also pending deletion, this filter now puts it in enabledTaxRates, so enabledTaxRatesNames contains its modifiedName. The selected option passed by TaxPicker only carries modifiedName (not pendingAction or code), so the later selected-option branch marks it isDisabled: false and enabledTaxRatesWithoutSelectedOptions removes the real pending-delete row; the picker then renders the deleted selected tax as selectable and can submit it with code undefined instead of showing the struck-through non-selectable row described here.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 664da18.
Good catch — when the selected default rate was also pending deletion, the new enabledTaxRates filter leaked it into enabledTaxRatesNames, so the selected-option branch marked it isDisabled: false and it rendered as a selectable row (submittable with an undefined code).
Two changes:
TaxOptionsListUtils.ts:79— exclude pending-DELETE rates fromenabledTaxRatesNames, so a selected rate that is pending deletion is no longer treated as enabled/selectable.TaxOptionsListUtils.ts:93-99— sinceselectedOptionsonly carrymodifiedName, forward the underlying rate'spendingAction/codeso the selected pending-delete row still renders struck-through and non-selectable.
Added a regression case to TaxOptionsListUtilsTest.ts passing the deleted rate as a selected option and asserting it comes back isDisabled: true, pendingAction: 'delete', with its code. npm run test, typecheck-tsgo, lint, and fmt all pass.
There was a problem hiding this comment.
This concern was already addressed in follow-up commit 664da18 (co-authored by bernhardoj), which landed after this review comment was posted. No further change is needed — here's why the edge case is covered:
TaxOptionsListUtils.ts:82—enabledTaxRatesNamesnow excludes pending-DELETErates. So a selected rate that is pending deletion is not in that set, and theisDisabled: falsebranch atTaxOptionsListUtils.ts:89is skipped for it.TaxOptionsListUtils.ts:95-99— instead, the selected pending-delete option is pushed with the underlying rate'scodeandpendingActionandisDisabled: true, sogetTaxRatesOptionsrenders it struck-through, non-selectable, and with a definedcode(noundefined-code submission).
A regression test for exactly this scenario (a rate that is both selected and pending deletion) was also added at TaxOptionsListUtilsTest.ts:162.
(I couldn't execute the Jest suite in this run to re-confirm locally, but the fix and its regression test are present in the current branch head.)
There was a problem hiding this comment.
@MelvinBot that's not what I expected. What we need to do instead is update the selectedOptions so it has the pendingAction field too, so selectedTaxRateWithDisabledState tax item has the pendingAction, which will set the isDisabled to true
There was a problem hiding this comment.
@MelvinBot ignore my previous comment. Help me investigate why we optimistically disable the tax when deleting it.
There was a problem hiding this comment.
Done — reworked it to your approach in baca218.
Now the selected option itself carries pendingAction, so the pending-delete tax flows into selectedTaxRateWithDisabledState with pendingAction: 'delete', and getTaxRatesOptions forces isDisabled: true for it (struck-through, non-selectable).
TaxPicker.tsx:112-127— look up the selected rate and setpendingActionon theselectedOptionsentry.TaxOptionsListUtils.ts:28— addpendingActionto theTaxtype so it's carried through.TaxOptionsListUtils.ts:80-92— reverted the previousenabledTaxRatesNamesDELETE filter and thetaxRatesByModifiedNamelookup, since they're no longer needed.
Updated the regression test to pass pendingAction: 'delete' on the selected option. test, typecheck-tsgo, lint, and fmt all pass.
There was a problem hiding this comment.
It's intentional — the optimistic isDisabled: true was added on purpose in #48859 (Sep 2024) to fix #48290, so that a rate deleted while offline behaves as disabled during the pending-delete window, consistent with how categories (enabled: false) and tags are handled in the same delete flow.
The key signal that it's deliberate is the failure path, which restores the rate's original disabled state rather than clearing it — TaxRate.ts:394 (isDisabled: !!policyTaxRates?.[taxID]?.isDisabled). So the optimistic block flips it to disabled, and if the API call fails it rolls back to whatever it was.
Why "disabled" (not just pendingAction: DELETE) matters
Several consumers key off isDisabled alone and do not look at pendingAction, so marking the pending-delete rate disabled keeps it out of "enabled" counts/selection everywhere, not just where pendingAction is checked:
getEnabledTaxRateCount—TransactionUtils/index.ts:2193counts!option.isDisabled. This drivestaxRatesCountinTaxPicker.tsx:87(list threshold / search input).- The
enabledTaxRatesfilter inTaxOptionsListUtils.ts:79starts fromisDisabled. - Some paths do check both (e.g.
TransactionUtils/index.ts:2671uses!tax.isDisabled && tax.pendingAction !== DELETE), but the count/filter paths above rely onisDisabledonly.
The exact change from #48859 (TaxRate.ts:345):
- acc[taxID] = {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, errors: null};
+ acc[taxID] = {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, errors: null, isDisabled: true};(the same PR added enabled: false to the category and tag optimistic deletes.)
Bearing on this PR: this is exactly why the rate vanished from the default currency picker — getTaxRatesSection filtered out isDisabled rates, and the optimistic delete makes the rate isDisabled: true. Rather than dropping the optimistic isDisabled (which would revert #48290 and ripple through every isDisabled consumer above), keeping it and handling the pendingAction: DELETE case in the picker — as this PR does — is the narrower, safer fix.
|
The only failing check is PR Reviewer Checklist / checklist — there's nothing to fix in code here. That check isn't a CI/build/test failure; it's the manual reviewer checklist that stays red until a reviewer opens the PR and completes their checklist. Every actual automated check is green (Bun tests, Next step: this will clear on its own once a reviewer completes the PR Reviewer Checklist — no action needed from you. |
…ectable Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
|
@mjasikowski 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] |
|
The only failing check is Every automated check passes on the latest commit ( The |
|
The only failing check on this PR is PR Reviewer Checklist / checklist (run). Every other check (tests, typecheck, ESLint, Oxfmt, Storybook, perf, builds, etc.) is passing. This isn't a code failure I can push a fix for — the Reviewer Checklist fails until a human reviewer opens the checklist comment and completes/checks off its items. Once the assigned reviewer fills it out, that check will pass. No code change is needed here. |
|
Same as before: the only red check is PR Reviewer Checklist / checklist (latest run) — all functional checks (tests, typecheck, lint, builds, perf) are green. There's nothing to push here. This check stays failing until the assigned reviewer opens the checklist comment on the PR and completes its items; it isn't driven by the code. No code change will turn it green. |
| const enabledTaxRates = sortedTaxRates.filter((taxRate) => !taxRate.isDisabled); | ||
| // Keep rates that are pending deletion (e.g. deleted while offline) so they still render struck-through and non-selectable, | ||
| // instead of dropping them via the isDisabled filter. getTaxRatesOptions forces isDisabled for pending-DELETE rows. | ||
| const enabledTaxRates = sortedTaxRates.filter((taxRate) => !taxRate.isDisabled || taxRate.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); |
There was a problem hiding this comment.
@MelvinBot revert this change back to const enabledTaxRates = sortedTaxRates.filter((taxRate) => !taxRate.isDisabled);
There was a problem hiding this comment.
Done in 9ab5d44 — reverted TaxOptionsListUtils.ts:76 back to const enabledTaxRates = sortedTaxRates.filter((taxRate) => !taxRate.isDisabled); (and removed the now-inaccurate retention comment).
A pending-delete rate is once again dropped from the general list, since it's only kept visible when it's the currently selected option — the selectedOptions loop forwards its pendingAction (via taxRatesByModifiedName) so it still renders struck-through and non-selectable.
Updated TaxOptionsListUtilsTest.ts to match: a non-selected deleted rate no longer appears in the list or search, while the selected-deleted-rate case still asserts it shows struck-through. test, typecheck-tsgo, lint, and fmt all pass.
|
Still the same as before: the only failing check is PR Reviewer Checklist / checklist (run). All functional checks — tests, typecheck, ESLint, Oxfmt, Storybook, perf, builds — pass. There's no code fix to push here. That check only turns green once the assigned reviewer opens the checklist comment on this PR and completes its items. Nothing is broken in the code. |
Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
|
MelvinBot has made 5 consecutive commits trying to fix CI failures. Automatic CI fix dispatches are now paused for this PR. Next steps: A human should review the recent commits and resolve the conflicting CI errors manually. |
|
@MelvinBot now, update the Then, in AddTaxPage, filter out pending delete taxes for |
… AddTaxPage Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
|
Done in
|
|
@MelvinBot adjust the test that you updated |
…imistically disabled Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
|
Done in The deleted
|
| modifiedName: 'Tax rate 2 (3%)', | ||
| // A rate deleted while offline is marked with pendingAction DELETE only (see TaxRate.ts); it is no longer | ||
| // optimistically disabled, so it stays in the list but renders struck-through and non-selectable | ||
| // because getTaxRatesOptions forces isDisabled for pending-DELETE rows. |
There was a problem hiding this comment.
Removed in 67477fd.
| ]; | ||
|
|
||
| // The only rate whose name matches these searches is the deleted CODE2. It is no longer excluded from the list, | ||
| // so it is returned struck-through and non-selectable (isDisabled forced true by its pending-DELETE state). |
There was a problem hiding this comment.
Removed in 67477fd.
Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid.mp4Android: mWeb Chromeandroid.mweb.mp4iOS: HybridAppios.mp4iOS: mWeb Safariios.mweb.mp4MacOS: Chrome / Safariweb.mp4 |
Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
|
Removed in (Replying at the PR level because the triggering inline comment wasn't yet retrievable via the API when this ran.) |
|
@MelvinBot update all the test step to add a step between 4 and 5 |
|
Done — added |
|
@mjasikowski ready for your review |
|
🚧 mjasikowski has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/mjasikowski in version: 9.4.32-0 🚀
|
|
🤖 I reviewed this PR against the help site files under Why: This is a bug fix that restores already-expected behavior. Offline-deleted tax rates were disappearing from the Workspace currency default / Foreign currency default tax pickers; the fix keeps them visible (struck-through, non-selectable) to match the main Taxes page. It doesn't add a feature, change a workflow, rename a setting/tab/button, or introduce new capability. The tax help articles already describe the relevant flows accurately and don't document offline optimistic-update rendering, so nothing there is now inaccurate:
If you feel the offline delete behavior is worth documenting explicitly, let me know and I can draft an addition. |
|
🚀 Deployed to production by https://github.com/grgia in version: 9.4.32-3 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
When a tax rate is deleted while offline, the optimistic update in
TaxRate.tsmarks the rate with bothpendingAction: DELETEandisDisabled: true.The default tax rate picker (Settings > Workspace currency default / foreign currency default) builds its list with
getTaxRatesSection, which filtered out every rate whoseisDisabledwas truthy (TaxOptionsListUtils.ts:76). Because the pending-deleted rate now carriesisDisabled: true, it was dropped fromenabledTaxRatesand never emitted into any section, so it disappeared from the picker entirely instead of showing struck-through.The fix retains rates that are pending deletion in
getTaxRatesSection(keep a rate whenpendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE).getTaxRatesOptionsalready forcesisDisabled(non-selectable) and forwardspendingActionfor DELETE rows, so the retained rate renders struck-through and non-selectable — matching the main Taxes page and the Expected Result. This covers both the workspace-currency and foreign-currency default pickers since both use the sameTaxPicker→getTaxRatesSectionpath.A regression test was added to
TaxOptionsListUtilsTest.ts: the existing fixture marked the deleted rate with onlypendingAction: 'delete'(which was never filtered), so it did not reproduce the bug. It now also setsisDisabled: trueto reflect the real optimistic delete state, and asserts the rate still appears struck-through and non-selectable. This test fails without the source change and passes with it.Fixed Issues
$ #95231
PROPOSAL: #95231 (comment)
Tests
Offline tests
Same as Tests (the bug only manifests while offline).
QA Steps
PR Author Checklist
checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)Avatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: HybridApp
android.mp4
Android: mWeb Chrome
android.mweb.mp4
iOS: HybridApp
ios0.mp4
iOS: mWeb Safari
ios.mp4
MacOS: Chrome / Safari
web.mp4