Skip to content
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-05-09] [HOLD for payment 2024-05-08] HIGH: [API Reliability] [$250] Multiple calls to OpenReport on signin #39673

Closed
1 of 6 tasks
m-natarajan opened this issue Apr 5, 2024 · 38 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@m-natarajan
Copy link

m-natarajan commented Apr 5, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 1.4.60-7
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @quinthar
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1712180869292309

Action Performed:

  1. Sign in to NewDot

Expected Result:

Only one OpenReport is called since I open it only once

Actual Result:

It is called twice

Workaround:

unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Screen Shot 2024-04-04 at 8 51 35 PM

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0138cc8ab53b98e8c0
  • Upwork Job ID: 1777757590524878848
  • Last Price Increase: 2024-04-16
  • Automatic offers:
    • abdulrahuman5196 | Reviewer | 0
    • bernhardoj | Contributor | 0
Issue OwnerCurrent Issue Owner: @muttmuure
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Apr 5, 2024
Copy link

melvin-bot bot commented Apr 5, 2024

Triggered auto assignment to @muttmuure (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@bernhardoj
Copy link
Contributor

bernhardoj commented Apr 6, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

There are 2 duplicate OpenReport request when opening a report for the first time, for example after sign in.

What is the root cause of that problem?

The first OpenReport is called when ReportScreen is mounted (fetchReportIfNeeded).

useEffect(() => {
Timing.end(CONST.TIMING.CHAT_RENDER);
Performance.markEnd(CONST.TIMING.CHAT_RENDER);
fetchReportIfNeeded();

The second OpenReport is called when ReportActionsView is also mounted (openReportIfNecessary).

useEffect(() => {
if (reportActionID) {
return;
}
const interactionTask = InteractionManager.runAfterInteractions(() => {
openReportIfNecessary();
});

Both openReportIfNecessary and openReportIfNecessary won't call OpenReport if shouldFetchReport is false.

if (!shouldFetchReport(report)) {
return;
}

If shouldFetchReport is true, then the difference between openReportIfNecessary and openReportIfNecessary is, fetchReportIfNeeded won't call OpenReport if the report already exists

// It is possible that we may not have the report object yet in Onyx yet e.g. we navigated to a URL for an accessible report that
// is not stored locally yet. If report.reportID exists, then the report has been stored locally and nothing more needs to be done.
// If it doesn't exist, then we fetch the report from the API.
if (report.reportID && report.reportID === reportIDFromRoute && !reportMetadata?.isLoadingInitialReportActions) {
return;
}

but openReportIfNecessary will always call it.

const openReportIfNecessary = () => {
if (!shouldFetchReport(report)) {
return;
}
Report.openReport(reportID, reportActionID);
};

What changes do you think we should make in order to solve the problem?

First, don't call openReportIfNecessary when ReportActionsView is mounted. Then, we need to decide whether we should always call OpenReport or not when ReportScreen is mounted even when we already have the report object. I would say yes so we always get the latest report data every time we visit a chat (and also because we did this in ReportActionsView, so the behavior is unchanged).

We can do that by removing this condition.

if (report.reportID && report.reportID === reportIDFromRoute && !reportMetadata?.isLoadingInitialReportActions) {
return;
}

@melvin-bot melvin-bot bot added the Overdue label Apr 8, 2024
Copy link

melvin-bot bot commented Apr 8, 2024

@muttmuure Whoops! This issue is 2 days overdue. Let's get this updated quick!

@muttmuure muttmuure added the External Added to denote the issue can be worked on by a contributor label Apr 9, 2024
Copy link

melvin-bot bot commented Apr 9, 2024

Job added to Upwork: https://www.upwork.com/jobs/~0138cc8ab53b98e8c0

@melvin-bot melvin-bot bot changed the title HIGH: [Reliability] Multiple calls to OpenReport on signin [$250] HIGH: [Reliability] Multiple calls to OpenReport on signin Apr 9, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 9, 2024
@muttmuure
Copy link
Contributor

Adding external

Copy link

melvin-bot bot commented Apr 9, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @abdulrahuman5196 (External)

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Apr 9, 2024
@abdulrahuman5196
Copy link
Contributor

Checking now

@melvin-bot melvin-bot bot removed the Overdue label Apr 12, 2024
@abdulrahuman5196
Copy link
Contributor

@bernhardoj I understand both ReportScreen.tsx and ReportActionsView.tsx component mount has OpenReport has in it.
But the thing i don't understand is, why is this happening only at signin?, since it doesn't happen when we open a chat after that.
I noticied, that OpenReport is called multiple times only when having a skeleton loading. What is the co-relation here?

I support removing the openReport call inside ReportActionsView, but wanted to be sure we won't cause any issue since its a super old code.

@bernhardoj
Copy link
Contributor

But the thing i don't understand is, why is this happening only at signin?, since it doesn't happen when we open a chat after that.
I noticied, that OpenReport is called multiple times only when having a skeleton loading. What is the co-relation here?

image

I mentioned here that ReportScreen won't call OpenReport if the report object already exists. There is also a !reportMetadata?.isLoadingInitialReportActions condition which will be false when you open an existing report, but never load it yet. If you never load it yet, then the isLoadingInitialReportActions value will be true (default)

reportMetadata: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_METADATA}${getReportID(route)}`,
initialValue: {
isLoadingInitialReportActions: true,

@melvin-bot melvin-bot bot added the Overdue label Apr 15, 2024
@abdulrahuman5196
Copy link
Contributor

@bernhardoj If I disble ReportActionsView OpenReport API call, there isn't any OpenReport API call not made when opening a report.

Screen.Recording.2024-04-15.at.11.51.48.PM.mov

@melvin-bot melvin-bot bot removed the Overdue label Apr 15, 2024
Copy link

melvin-bot bot commented Apr 15, 2024

@abdulrahuman5196, @muttmuure Whoops! This issue is 2 days overdue. Let's get this updated quick!

@bernhardoj
Copy link
Contributor

@abdulrahuman5196 yep, that's why I propose to remove the existing report condition from the ReportScreen

Then, we need to decide whether we should always call OpenReport or not when ReportScreen is mounted even when we already have the report object. I would say yes so we always get the latest report data every time we visit a chat (and also because we did this in ReportActionsView, so the behavior is unchanged).

I have updated my proposal to point out which code to remove

@twisterdotcom twisterdotcom changed the title [$250] HIGH: [Reliability] Multiple calls to OpenReport on signin [$250] CRITICAL: [Reliability] Multiple calls to OpenReport on signin Apr 16, 2024
Copy link

melvin-bot bot commented Apr 16, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@quinthar quinthar changed the title [$250] CRITICAL: [Reliability] Multiple calls to OpenReport on signin HIGH: [Reliability] [$250] Multiple calls to OpenReport on signin Apr 17, 2024
@melvin-bot melvin-bot bot added the Overdue label Apr 17, 2024
Copy link

melvin-bot bot commented May 1, 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:

  • [@abdulrahuman5196] The PR that introduced the bug has been identified. Link to the PR:
  • [@abdulrahuman5196] 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:
  • [@abdulrahuman5196] 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:
  • [@abdulrahuman5196] Determine if we should create a regression test for this bug.
  • [@abdulrahuman5196] 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.
  • [@muttmuure] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@abdulrahuman5196
Copy link
Contributor

@bernhardoj The PR has been reverted due to an issue. Kindly raise a another PR fixing the regression as well.

@bernhardoj
Copy link
Contributor

@abdulrahuman5196 new PR is ready

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels May 2, 2024
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2024-05-08] HIGH: [API Reliability] [$250] Multiple calls to OpenReport on signin [HOLD for payment 2024-05-09] [HOLD for payment 2024-05-08] HIGH: [API Reliability] [$250] Multiple calls to OpenReport on signin May 2, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label May 2, 2024
Copy link

melvin-bot bot commented May 2, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented May 2, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.69-2 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-05-09. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented May 2, 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:

  • [@abdulrahuman5196] The PR that introduced the bug has been identified. Link to the PR:
  • [@abdulrahuman5196] 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:
  • [@abdulrahuman5196] 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:
  • [@abdulrahuman5196] Determine if we should create a regression test for this bug.
  • [@abdulrahuman5196] 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.
  • [@muttmuure] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels May 7, 2024
@muttmuure
Copy link
Contributor

Awaiting payment date

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels May 8, 2024
Copy link

melvin-bot bot commented May 13, 2024

@flodnv, @abdulrahuman5196, @muttmuure, @bernhardoj Eep! 4 days overdue now. Issues have feelings too...

@flodnv
Copy link
Contributor

flodnv commented May 14, 2024

@muttmuure can we pay and close this?

@muttmuure
Copy link
Contributor

Automation has failed, I will create a payment in Upwork tomorrow

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels May 14, 2024
Copy link

melvin-bot bot commented May 20, 2024

@flodnv, @abdulrahuman5196, @muttmuure, @bernhardoj Huh... This is 4 days overdue. Who can take care of this?

@muttmuure
Copy link
Contributor

Paid

@melvin-bot melvin-bot bot removed the Overdue label May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
No open projects
Development

No branches or pull requests

6 participants