Skip to content

Remove Onyx.connect() usage for ONYXKEYS.COLLECTION.POLICY_TAGS from duplicateReport#95738

Merged
amyevans merged 5 commits into
Expensify:mainfrom
software-mansion-labs:Guccio163/onyx-connect/policy_tags/requestMoney_createExpenseByType
Jul 14, 2026
Merged

Remove Onyx.connect() usage for ONYXKEYS.COLLECTION.POLICY_TAGS from duplicateReport#95738
amyevans merged 5 commits into
Expensify:mainfrom
software-mansion-labs:Guccio163/onyx-connect/policy_tags/requestMoney_createExpenseByType

Conversation

@Guccio163

@Guccio163 Guccio163 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Removes the deprecated getMoneyRequestPolicyTags (Onyx.connect-based) usage from src/libs/actions/IOU/Duplicate.ts and relies on the policy tags that are already passed down reactively via useOnyx.

  • duplicateReport now uses the targetPolicyTags param (resolved in bulkDuplicateReports / useExpenseActions from the useOnyx-provided allPolicyTags, indexed by the target policy) instead of computing tags via the deprecated getMoneyRequestPolicyTags. This also removes a currentIOUReport temporal-dead-zone issue.
  • createExpenseByType no longer takes a separate policyTagList argument; it reads the tags from params.policyParams, which the callers populate.
  • duplicateExpenseTransaction sets policyParams.policyTagList from its policyTagList param.
  • Removed the now-redundant policyParams: params.policyParams overrides (the ...params spread already carries it) and the now-unused imports (getMoneyRequestPolicyTags, getReportOrDraftReport, isMoneyRequestReport).

Equivalence: newReport.policyID === targetPolicy.id, so the old getMoneyRequestPolicyTags(...) (whose priority starts at existingIOUReport.policyID) always resolved to getPolicyTagsData(targetPolicy.id) — the same value as the passed-down targetPolicyTags = allPolicyTags[targetPolicy.id], only via a deprecated global read instead of the reactive useOnyx path.

Fixed Issues

$ #72721
PROPOSAL:

Tests

  1. Sign in to New Expensify and open a workspace that has tags enabled (Workspace settings → Tags → add at least one tag list with tags).
  2. In that workspace chat, submit an expense and add a tag to it, so there is a report with at least one tagged expense.
  3. Open the report, tap the header/more menu (⋮), and select Duplicate report.
  4. Verify a copy of the report is created on the same workspace with the expense(s), and the tags on the duplicated expense(s) match the workspace's tags.
  5. Open Reports (or Search), enable selection mode, select one or more reports, and choose Duplicate from the bulk actions menu.
  6. Verify the duplicated reports are created with their expenses and correct tags.
  7. Verify that no errors appear in the JS console.
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

Same as tests.

  • 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 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 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

Guccio163 added 2 commits July 9, 2026 19:09
…duplicateReport

Drop the deprecated getMoneyRequestPolicyTags computation from Duplicate.ts and rely on the policy tags passed down reactively:

- duplicateReport now uses the targetPolicyTags param (resolved in bulkDuplicateReports from the useOnyx-provided allPolicyTags) instead of computing them via the deprecated getMoneyRequestPolicyTags
- createExpenseByType no longer takes a policyTagList override; it uses params.policyParams
- duplicateExpenseTransaction sets policyParams.policyTagList from its policyTagList param
- removed now-unused imports (getMoneyRequestPolicyTags, getReportOrDraftReport, isMoneyRequestReport)

Part of the Onyx.connect migration (Expensify#72721).
The spread of `...params` already carries `params.policyParams` (which includes the policyTagList set by the callers), so the explicit `policyParams: params.policyParams` in the DISTANCE and default branches was redundant.
@Guccio163
Guccio163 requested review from a team as code owners July 9, 2026 17:28
@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and parasharrajat and removed request for a team July 9, 2026 17:28
@melvin-bot

melvin-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

@parasharrajat 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]

@codecov

codecov Bot commented Jul 9, 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/hooks/useMoneyRequestPolicyTags.ts 100.00% <ø> (ø)
src/libs/actions/IOU/Duplicate.ts 91.64% <ø> (-0.16%) ⬇️
src/libs/actions/IOU/index.ts 100.00% <ø> (+3.57%) ⬆️
... and 20 files with indirect coverage changes

@Guccio163 Guccio163 changed the title Remove Onyx.connect() usage for ONYXKEYS.COLLECTION.POLICY_TAGS from duplicateReport [Blocked by #95716] Remove Onyx.connect() usage for ONYXKEYS.COLLECTION.POLICY_TAGS from duplicateReport Jul 9, 2026
@Guccio163

Copy link
Copy Markdown
Contributor Author

This issue will be the last of the getMoneyRequestInformation follow-ups, removing deprecated getMoneyRequestPolicyTags function after createTransaction PR gets merged

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

No product review required.

@Guccio163 Guccio163 changed the title [Blocked by #95716] Remove Onyx.connect() usage for ONYXKEYS.COLLECTION.POLICY_TAGS from duplicateReport Remove Onyx.connect() usage for ONYXKEYS.COLLECTION.POLICY_TAGS from duplicateReport Jul 13, 2026
…-fork into Guccio163/onyx-connect/policy_tags/requestMoney_createExpenseByType
@Guccio163

Copy link
Copy Markdown
Contributor Author

@parasharrajat #95716 got merged, so we're good to also wrap this 🌪️

@parasharrajat parasharrajat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

🎀 👀 🎀 C+ reviewed

@melvin-bot
melvin-bot Bot requested a review from amyevans July 14, 2026 18:02

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

There's a conflict to fix @Guccio163

…-fork into Guccio163/onyx-connect/policy_tags/requestMoney_createExpenseByType
@Guccio163

Copy link
Copy Markdown
Contributor Author

@amyevans fixed ✅

@amyevans
amyevans merged commit 2135bf7 into Expensify:main Jul 14, 2026
34 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

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

@OSBotify

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

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/amyevans in version: 9.4.35-1 🚀

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, so I did not create a draft PR.

Why: This PR is a purely internal code refactor. It removes the deprecated Onyx.connect()-based getMoneyRequestPolicyTags read from duplicateReport and instead relies on the policy tags already passed down reactively via useOnyx. The PR description documents that these paths are equivalent (newReport.policyID === targetPolicy.id, so the old global read always resolved to the same value as the reactive targetPolicyTags).

The three touched files are all internal implementation (src/hooks/useMoneyRequestPolicyTags.ts, src/libs/actions/IOU/Duplicate.ts, src/libs/actions/IOU/index.ts). There is no change to the Duplicate report / bulk Duplicate feature behavior, no new or renamed UI elements, settings, tabs, or buttons, and no change to tag behavior that a user would observe. Nothing in the current help-site content describes the internal data-fetch mechanism being changed here, so there is nothing to update.

If you believe this changes user-facing behavior that should be documented, let me know what the observable difference is and I'll draft the corresponding article update.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/jasperhuangg in version: 9.4.35-6 🚀

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

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