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
[$250] 3 OpenReport API calls for the same report #49948
Please re-state the problem that we are trying to solve in this issue.
There are 2 OpenReport calls when open a thread that we never loaded yet.
What is the root cause of that problem?
The 1st OpenReport is called in this effect. The purpose of this effect is to call the OpenReport on mount, but we only want to call it when the report onyx is already loaded. We did this after migrating from withOnyx to useOnyx here.
When we open the thread that we haven't loaded yet, the report will initially be undefined. The 1st OpenReport will optimistically merge the reportName as Chat Report.
Because onyxReportID (empty string) is different from prevReport?.reportID (undefined), the 2nd OpenReport is called. After the 1st OpenReport is finished, the onyxReportID is updated to the correct reportID (X). Again, because the onyxReportID (X) is different from prevReport?.reportID (empty string), the 3rd OpenReport is called.
What changes do you think we should make in order to solve the problem?
There are 2 solutions. First, if we see the comment here,
it's mentioned that when deeplinking from a report to another report, the report screen is not unmounted and the reportID param is not updated, so the old conditions doesn't work when comparing prev reportID params to the current reportID params.
The report screen is not unmounted part is still true today because if we deeplink to the same screen with a different params, react-navigation will just update the screen params, so this part isn't true anymore.
the reportID in the route also doesn't change.
So, the first solution is to use the old conditions by comparing the prev reportID params and the current reportID params.
if (prevReportIDFromRoute === reportIDFromRoute) {
return;
}
The second solution is to push a new screen if the reportID is different. To do that, we can override the deeplink here.
Activity
melvin-bot commentedon Sep 30, 2024
Triggered auto assignment to @VictoriaExpensify (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.bernhardoj commentedon Oct 1, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
There are 2 OpenReport calls when open a thread that we never loaded yet.
What is the root cause of that problem?
The 1st OpenReport is called in this effect. The purpose of this effect is to call the OpenReport on mount, but we only want to call it when the report onyx is already loaded. We did this after migrating from withOnyx to useOnyx here.
App/src/pages/home/ReportScreen.tsx
Lines 489 to 496 in 69483ff
The 2nd and 3rd call is triggered from this effect.
App/src/pages/home/ReportScreen.tsx
Lines 577 to 588 in 69483ff
When we open the thread that we haven't loaded yet, the report will initially be undefined. The 1st OpenReport will optimistically merge the reportName as Chat Report.
App/src/libs/actions/Report.ts
Lines 779 to 783 in 69483ff
This will update the report to
{reportName: 'Chat Report'}, and so, the report onyx now contains an emptyreportID.App/src/pages/home/ReportScreen.tsx
Lines 169 to 173 in 69483ff
Because
onyxReportID(empty string) is different fromprevReport?.reportID(undefined), the 2nd OpenReport is called. After the 1st OpenReport is finished, theonyxReportIDis updated to the correct reportID (X). Again, because theonyxReportID(X) is different fromprevReport?.reportID(empty string), the 3rd OpenReport is called.What changes do you think we should make in order to solve the problem?
There are 2 solutions. First, if we see the comment here,
App/src/pages/home/ReportScreen.tsx
Lines 577 to 585 in 69483ff
it's mentioned that when deeplinking from a report to another report, the report screen is not unmounted and the reportID param is not updated, so the old conditions doesn't work when comparing prev reportID params to the current reportID params.

The report screen is not unmounted part is still true today because if we deeplink to the same screen with a different params, react-navigation will just update the screen params, so this part isn't true anymore.
So, the first solution is to use the old conditions by comparing the prev reportID params and the current reportID params.
The second solution is to push a new screen if the reportID is different. To do that, we can override the deeplink here.
App/src/libs/Navigation/linkingConfig/subscribe/index.native.ts
Lines 21 to 29 in 69483ff
Then, we can remove the OpenReport call here.
App/src/pages/home/ReportScreen.tsx
Lines 577 to 585 in 69483ff
[-]3 OpenReport API calls for the same report[/-][+][$250] 3 OpenReport API calls for the same report[/+]melvin-bot commentedon Oct 2, 2024
Job added to Upwork: https://www.upwork.com/jobs/~021841330786260257123
melvin-bot commentedon Oct 2, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @shubham1206agra (
External)VictoriaExpensify commentedon Oct 2, 2024
I think #vip-vsb is the best place for this since it's related to threads
melvin-bot commentedon Oct 7, 2024
@VictoriaExpensify, @shubham1206agra Huh... This is 4 days overdue. Who can take care of this?
38 remaining items
melvin-bot commentedon Nov 6, 2024
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
melvin-bot commentedon Nov 11, 2024
@VictoriaExpensify, @shubham1206agra Huh... This is 4 days overdue. Who can take care of this?
melvin-bot commentedon Nov 13, 2024
@VictoriaExpensify, @shubham1206agra Still overdue 6 days?! Let's take care of this!
VictoriaExpensify commentedon Nov 13, 2024
hey @shubham1206agra - can you please check the conversation Ioni linked here - #49948 (comment)
It looks like this issue is still happening
melvin-bot commentedon Nov 13, 2024
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
melvin-bot commentedon Nov 15, 2024
@VictoriaExpensify, @shubham1206agra Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!
mvtglobally commentedon Nov 16, 2024
Issue not reproducible during KI retests. (First week)
melvin-bot commentedon Nov 19, 2024
@VictoriaExpensify, @shubham1206agra 12 days overdue now... This issue's end is nigh!
shubham1206agra commentedon Nov 19, 2024
@VictoriaExpensify Please close this
muttmuure commentedon Nov 19, 2024
Fixed over here: #51680