You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2024-04-15] [$250] Remove deprecated ReportUtils.getPolicy() method #38959
This is coming from #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
There are total 2 components & 18 util functions which uses getPolicy, from there we need to remove the use of getPolicy and add extra parameter for policy.
OPTION: We can create a local function in action file to get the policy with policyID and use this in other place of this file that we want.
Add a test here to verify that we do not export getPolicy function in ReportUtils
it('does not export getPolicy', () => {
// @ts-expect-error the test is asserting that it's undefined, so the TS error is normal
expect(ReportUtils.getPolicy).toBeUndefined();
});
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.60-13 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
[@DylanDylann] The PR that introduced the bug has been identified. Link to the PR:
[@DylanDylann] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
[@DylanDylann] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
[@DylanDylann] Determine if we should create a regression test for this bug.
[@DylanDylann] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
[@CortneyOfstad] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
[@DylanDylann] The PR that introduced the bug has been identified. Link to the PR: NA
[@DylanDylann] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: NA
[@DylanDylann] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: NA
[@DylanDylann] Determine if we should create a regression test for this bug. No
[@DylanDylann] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
Activity
melvin-bot commentedon Mar 25, 2024
Job added to Upwork: https://www.upwork.com/jobs/~010ae8bb081ab888f1
melvin-bot commentedon Mar 25, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @eVoloshchak (
External)melvin-bot commentedon Mar 25, 2024
Triggered auto assignment to @CortneyOfstad (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.Krishna2323 commentedon Mar 25, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Remove deprecated ReportUtils.getPolicy() method
What is the root cause of that problem?
Remove deprecated ReportUtils.getPolicy() method
What changes do you think we should make in order to solve the problem?
Steps:
getPolicyfrom here:App/src/libs/ReportUtils.ts
Lines 570 to 579 in c1947c2
getPolicy, from there we need to remove the use ofgetPolicyand add extra parameter forpolicy.Note: For components we will use
withOnyx()Result
abzokhattab commentedon Mar 25, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Remove deprecated ReportUtils.getPolicy() method
What is the root cause of that problem?
Remove deprecated ReportUtils.getPolicy() method.
What changes do you think we should make in order to solve the problem?
we need to remove the
ReportUtil.getPolicy()App/src/components/SettlementButton.tsx
Line 142 in 0047ad2
and, here
App/src/pages/workspace/WorkspaceJoinUserPage.tsx
Line 32 in 058f2d9
and replace it with oynx similar to the following snippet
then here
App/src/libs/NextStepUtils.ts
Line 75 in cb71f33
Onyx.connecton top to get the policy using the given id.also we need to the do same in all the occurencies inside the
IOU.jsand in thePolicy.tsfilesnayabatir1 commentedon Mar 25, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Remove deprecated
ReportUtils.getPolicy().What is the root cause of that problem?
Since
ReportUtils.getPolicy()is deprecated need to replace it everywhere withwithOnyxorOnyx.connect()to get dataWhat changes do you think we should make in order to solve the problem?
SettlementButton.tsxNextStepUtils.tsReportUtils.tsPolicy.tsWorkspaceJoinUserPage.tsxgetPolicyis not exported fromReportUtils.tsWhat alternative solutions did you explore? (Optional)
nkdengineer commentedon Mar 26, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Remove deprecated ReportUtils.getPolicy() method
What is the root cause of that problem?
What changes do you think we should make in order to solve the problem?
policyviawithOnyxof if the component already subscribe the policy collection, we will get thepolicyfrom thisApp/src/components/SettlementButton.tsx
Line 262 in d8361ee
App/src/pages/workspace/WorkspaceJoinUserPage.tsx
Line 32 in d8361ee
Onyx.connectto getallPoliciesand then use this to get the policyOPTION: We can create a local function in action file to get the policy with
policyIDand use this in other place of this file that we want.getPolicyfunction inReportUtilsApp/tests/actions/EnforceActionExportRestrictions.ts
Line 8 in d8361ee
What alternative solutions did you explore? (Optional)
NA
35 remaining items
melvin-bot commentedon Apr 8, 2024
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Apr 8, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.60-13 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2024-04-15. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Apr 8, 2024
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
nkdengineer commentedon Apr 10, 2024
@DylanDylann Create a follow up PR here #39991 to fix the bug that is mentioned by @Pujan92 above #38959 (comment).
CortneyOfstad commentedon Apr 15, 2024
So there was a regression, so this will result in a price of $250 instead of $500 for both @DylanDylann and @nkdengineer.
@DylanDylann can you handle the checklist here by EOD?
@nkdengineer I sent you a manual offer in Upwork. Please let me know once you accept 👍
DylanDylann commentedon Apr 15, 2024
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
[@DylanDylann] The PR that introduced the bug has been identified. Link to the PR: NA
[@DylanDylann] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: NA
[@DylanDylann] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: NA
[@DylanDylann] Determine if we should create a regression test for this bug. No
[@DylanDylann] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
DylanDylann commentedon Apr 15, 2024
This is clean up issue, so I think we don't need regression test step
CortneyOfstad commentedon Apr 15, 2024
Sounds good @DylanDylann!
CortneyOfstad commentedon Apr 15, 2024
Payment Summary
@DylanDylann — paid $250 via Upwork
@nkdengineer — paid $250 via Upwork