Skip to content

[No QA] update previousTaxCode in setPolicyTaxCode successData#94286

Merged
MonilBhavsar merged 3 commits into
Expensify:mainfrom
dukenv0307:fix/94003
Jul 9, 2026
Merged

[No QA] update previousTaxCode in setPolicyTaxCode successData#94286
MonilBhavsar merged 3 commits into
Expensify:mainfrom
dukenv0307:fix/94003

Conversation

@dukenv0307

@dukenv0307 dukenv0307 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Currently, we are using

[newTaxCode]: {
                                ...originalTaxRate,

in successData, so previousTaxCode will be overridden to the outdated data.

In this PR, I update previousTaxCode to the correct value.

Fixed Issues

$ #94003
PROPOSAL:

Tests

  1. Open the ND tax page
  2. Select any tax
  3. Edit tax rate, name, or code
  4. Open Chrome devtool -> Application -> IndexDB -> Search for the policy
  5. Verify that the code and previousTaxCode are correct
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • 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 followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and 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 followed the guidelines as stated in the Review Guidelines
  • 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • 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.
  • 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

@dukenv0307 dukenv0307 marked this pull request as ready for review June 28, 2026 10:01
@dukenv0307 dukenv0307 requested review from a team as code owners June 28, 2026 10:01
@melvin-bot melvin-bot Bot requested review from dmkt9, heyjennahay and truph01 and removed request for a team June 28, 2026 10:01
@melvin-bot

melvin-bot Bot commented Jun 28, 2026

Copy link
Copy Markdown

@truph01 @dmkt9 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]

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 996e18e9ce

ℹ️ 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".

pendingFields: {...originalTaxRate.pendingFields, code: null},
pendingAction: null,
errorFields: {code: null},
previousTaxCode: oldTaxCode,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Clear stale tax-code aliases after success

Keeping previousTaxCode in the confirmed Onyx state makes the old code a permanent alias for this rate. If the user later reuses that old code for another tax, validateTaxCode/isExistingTaxCode only reject existing object keys, and the old key was removed; then WorkspaceEditTaxPage calls getCurrentTaxID(), which can return this renamed rate via previousTaxCode before it reaches the real reused-code key. In that scenario the edit route for the newly reused code redirects to this renamed tax, so the new tax cannot be edited or deleted correctly.

Useful? React with 👍 / 👎.

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.

I introduced optimisticPreviousTaxCode to fix this issue cc @truph01

pendingFields: {...originalTaxRate.pendingFields, code: null},
pendingAction: null,
errorFields: {code: null},
previousTaxCode: oldTaxCode,

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.

@dukenv0307 I think we should update the previousTaxCode value for the policy in snapshot_ as well.

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.

@dmkt9 Do you mean update it optimistically or in BE?

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.

Yes, I mean we should update both.

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.

Can you give me the test steps to reproduce the bug (if we don't update snapshot)? I'll update it in the follow-up PR

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.

Sure. You can use my PR (#94007) for testing. Please refer to Test 4:

  1. Create a workspace.
  2. Enable Taxes and navigate to the Taxes page.
  3. Create two new tax rates (e.g., Tax A and Tax B).
  4. Open Tax A.
  5. Verify that the Tax Code field is empty.
  6. Click the Tax Code field, enter any value, and save the changes.
  7. Verify that the Tax Code field now contains a value.
  8. Create a couple of expenses using Tax A and Tax B.
  9. Navigate to Spend > Expenses.
  10. Enable the Tax Code column.
  11. Note that the Tax Code column displays empty values for those expenses

Expected Result:
Verify that the Tax Code column displays a value for expenses using Tax A, and is empty for expenses using Tax B.

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.

@MelvinBot can you please create the new issue in E/E repo?

@dukenv0307 dukenv0307 Jun 30, 2026

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.

@dmkt9 I can't reproduce, can you please check again? previousTaxCode is already in snapshots

Screen.Recording.2026-06-30.at.4.25.05.PM.mov

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.

@dmkt9 I can't reproduce, can you please check again? previousTaxCode is already in snapshots

Screen.Recording.2026-06-30.at.4.25.05.PM.mov

Ah, thanks! It works well for me.

@dukenv0307

Copy link
Copy Markdown
Contributor Author

Kindly bump @truph01

@truph01

truph01 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Reviewing...
Could you merge main @dukenv0307 ?

@dukenv0307

Copy link
Copy Markdown
Contributor Author

@truph01 done

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/libs/actions/TaxRate.ts 62.22% <ø> (ø)
src/libs/PolicyUtils.ts 77.05% <0.00%> (-0.18%) ⬇️
... and 13 files with indirect coverage changes

@dukenv0307

Copy link
Copy Markdown
Contributor Author

@truph01 bump

@truph01

truph01 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

@dukenv0307 I am still seeing the default tax code ID is shown in tax code column:

Screenshot 2026-07-06 at 14 22 09

Could you help check?

@truph01

truph01 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

@dukenv0307 Also, could you update the "Explanation of Change" section? I am assuming that your PR aims to fix: #94003 (comment)

@dukenv0307

Copy link
Copy Markdown
Contributor Author

@truph01 I updated the PR description

@dukenv0307 Also, could you update the "Explanation of Change" section? I am assuming that your PR aims to fix: #94003 (comment)

No, I just made sure the previousTaxCode is correct, so you can use it to hide the default tax code in #94007

@dmkt9

dmkt9 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

@dukenv0307 I am still seeing the default tax code ID is shown in tax code column:

@truph01 I think this PR only adds previousTaxCode

@truph01

truph01 commented Jul 6, 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 proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained """"why"""" the code was doing something instead of only explaining """"what"""" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and 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 that this PR follows the guidelines as stated in the Review Guidelines
  • 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 and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • 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.
  • 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-07-06.at.15.44.48.mov

@melvin-bot melvin-bot Bot requested a review from MonilBhavsar July 6, 2026 08:45
@MonilBhavsar

Copy link
Copy Markdown
Contributor

@MelvinBot can you please create the new issue in E/E repo?

@dukenv0307 was any issue ever created?

@MelvinBot

Copy link
Copy Markdown
Contributor

Yes — that issue was already created, so no new one is needed.

In response to dukenv0307's request on 2026-06-30, I filed the corresponding internal Expensify/Expensify issue that same day. It has since been closed as completed (today, 2026-07-06) — which matches this thread, where dukenv0307 and dmkt9 confirmed previousTaxCode is already present in the search snapshots, so no further backend change was required.

I won't open a duplicate. If you'd like the internal issue reference, I can share it internally (it's in a private repo, so I'm not linking it here on the public PR).

@dukenv0307

Copy link
Copy Markdown
Contributor Author

@MonilBhavsar yes, but I closed bc we couldn't reproduce

@MonilBhavsar

Copy link
Copy Markdown
Contributor

Nice, thanks 👍

@MonilBhavsar MonilBhavsar 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.

previousTaxCode is no longer used? Can we remove it?

Also mind adding QA steps please

@dukenv0307 dukenv0307 changed the title update previousTaxCode in setPolicyTaxCode successData [No QA] update previousTaxCode in setPolicyTaxCode successData Jul 7, 2026
@dukenv0307

Copy link
Copy Markdown
Contributor Author

@MonilBhavsar I think we don't need QA tests in this PR

previousTaxCode is no longer used? Can we remove it?

We still need it in #94007

@MonilBhavsar MonilBhavsar merged commit d8ec440 into Expensify:main Jul 9, 2026
38 of 39 checks passed
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🚧 MonilBhavsar has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

OSBotify commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

OSBotify commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/MonilBhavsar in version: 9.4.32-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Help site review: no changes required.

I reviewed the changes in this PR and no updates to Expensify's help site files under App/docs/articles are required.

Why: This is an internal state-management/data-correctness fix. It introduces an optimisticPreviousTaxCode field so that previousTaxCode isn't overwritten with stale data in the setPolicyTaxCode successData, and updates getCurrentTaxID to resolve the rate from that in-flight field. The changes are confined to Onyx state handling:

  • src/libs/actions/TaxRate.ts — tracks the old tax code during an in-flight edit
  • src/libs/PolicyUtils.ts — resolves the current tax ID using the new field
  • src/types/onyx/Policy.ts — adds the optimisticPreviousTaxCode type

There is no user-facing behavior change. Editing a tax rate's name, code, or rate works exactly as before from the user's perspective; only the underlying data bookkeeping is corrected. Help articles describe how to add/edit tax rates, not the internal Onyx fields, so no article is affected.

No draft docs PR was created.

@dukenv0307, please confirm you agree no help site changes are needed here.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/grgia in version: 9.4.32-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants