App: [HOLD for payment 2024-04-15] [$250] Remove deprecated `ReportUtils.getPolicy()` method
This is coming from https://github.com/Expensify/App/issues/27262. You can read the issue description there to get context behind the problem being solved and the mess being cleaned up.
Problem
ReportUtils.getPolicy() is called from a view component and other action files which is an anti-pattern.
Why this is important to fix
It maintains a more pure and exact flow of data through the react application. If the view is using policy data, then it needs to subscribe to the policy in Onyx so that it’s garaunteed that the data will never be stale or out-of-date.
Solution
- Use
withOnyx()to load the data in view components - Use
Onyx.connect()to load the data in other action files - Remove the usage of
ReportUtils.getPolicy()or at least prevent it from being exported by adding a test to https://github.com/Expensify/App/blob/main/tests/actions/EnforceActionExportRestrictions.ts
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~010ae8bb081ab888f1
- Upwork Job ID: 1772360821776945152
- Last Price Increase: 2024-03-25
- Automatic offers:
- DylanDylann | Contributor | 0
Issue Owner
Current Issue Owner: @CortneyOfstadAbout this issue
- Original URL
- State: closed
- Created 3 months ago
- Comments: 38 (28 by maintainers)
This is clean up issue, so I think we don’t need regression test step
Both proposals are very similar, but I will go with the one that included the mention of the tests as that is a very important point to keep this pattern from being repeated.
Thank you for the feedback. I believe that mentioning tests in the proposal is optional and shouldn’t be the core focus, but I understand your point.
Let’s see what @tgolen thinks as well. I am happy with whatever decision is made.