-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HOLD for payment 2024-07-10] [HOLD for payment 2024-07-02] [$500] Remove exported ReportUtils.getReport()
#40316
Comments
ReportUtils.getReport()
ReportUtils.getReport()
Job added to Upwork: https://www.upwork.com/jobs/~014f8c2e6e8d2c1390 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @s77rt ( |
Triggered auto assignment to @MitchExpensify ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.Remove exported ReportUtils.getReport() What is the root cause of that problem?This is a polish issue. What changes do you think we should make in order to solve the problem?There are currently 28 places using let allReports: OnyxCollection<Report>;
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => (allReports = value),
}); withOnyx(
report: {
key: ({chatReportID}) => `${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`,
},
) What alternative solutions did you explore? (Optional)NA |
ProposalPlease re-state the problem that we are trying to solve in this issue.Remove deprecated ReportUtils.getReport() method What is the root cause of that problem?This is refactor issue What changes do you think we should make in order to solve the problem?
OPTION: We can create a local function in action file to get the report with
What alternative solutions did you explore? (Optional)NA |
@tgolen have we already found a way to synchronize all the Onyx reads? Using |
If most of the code used |
I'm not quite sure how this should help. The first thread was about For the record, |
Yes, this is what I mean. If the report was already fetched in the component, then the report should be passed directly to Keep in mind, I am only speaking to the theory behind it. It's been a long time since I've dug into the |
Passing objects around as parameters just because we cannot reliably fetch them from any place feels like a heavier anti-pattern than the one we are trying to solve by removing |
I think it reflects what I would expect for large collections. This is why I think
I'm not flatly against a singleton, but I think that is a last resort and I have always been concerned that it's the "easy solution" which covers up deeper problems. I'd rather fix the deeper problems, and only when those are completely exhausted, consider using a singleton. |
Why would that be needed? Or what's the difference between calling |
@gijoe0295 @nkdengineer Thank you for your proposals. Given this is a straightforward feature/refactor request we should go with the first proposal (@gijoe0295's proposal) 🎀 👀 🎀 C+ reviewed |
Current assignee @tgolen is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new. |
Before accepting any proposals... @gijoe0295 did you take a look at the references to see if it's easy (or even possible) to get the report using |
Regarding memory usage, I don't think there is that big of an impact. They should all be references to the same objects, so memory is negligible. If I'm wrong about that, please profile it and show the memory problem exists and is significant enough to be concerned about.
You're right that there is no technical difference between the two. The difference for me is a code quality and maintenance issue. As soon as |
@tgolen I investigated and verified that we can use We can optionally migrate to |
Great, thank you for confirming that. Using |
ReportUtils.getReport()
ReportUtils.getReport()
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.1-19 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-07-02. 🎊 For reference, here are some details about the assignees on 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:
|
Payment summary:
|
Checklist ^ does not apply here. Not a bug |
Paid and contract ended for @s77rt Please accept this offer @nkdengineer so I can do the same for you: https://www.upwork.com/nx/wm/offer/102706170, thanks! |
@MitchExpensify Payment due is $250. -50% for regression #43632 (comment). I have refunded $250. |
@MitchExpensify I accepted the offer too, thanks |
ReportUtils.getReport()
ReportUtils.getReport()
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.3-7 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-07-10. 🎊 For reference, here are some details about the assignees on 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:
|
Paid! Thanks @nkdengineer |
This is coming from #27262. You can read the issue description there to get the context behind the problem being solved and the mess being cleaned up.
Problem
ReportActionUtils.getReport()
is called from many view components 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 report action data, then it needs to subscribe to the data in Onyx so that it's guaranteed that the data will never be stale or out-of-date.
Solution
useOnyx()
to load the data in view componentsOnyx.connect()
to load the data in other action filesReportUtils.getReport()
and prevent it from being exported by adding a test to https://github.com/Expensify/App/blob/main/tests/actions/EnforceActionExportRestrictions.tsUpwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @MitchExpensifyThe text was updated successfully, but these errors were encountered: