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

[$500] Expense - App auto-redirects to expense report from main chat after returning online #35433

Closed
3 of 6 tasks
lanitochka17 opened this issue Jan 30, 2024 · 31 comments
Closed
3 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@lanitochka17
Copy link

lanitochka17 commented Jan 30, 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.33-4
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: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Go offline
  2. Request money in workspace chat
  3. Click on the expense preview twice to go to expense details page
  4. Click on the header subtitle twice to return to the main chat
  5. Go online
  6. Wait for a while

Expected Result:

App will stay in the main chat

Actual Result:

App redirects to expense report after returning online

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

Bug6361305_1706642435075.20240130_092358__1_.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~017a5665dbb6dad48c
  • Upwork Job ID: 1752425346704171008
  • Last Price Increase: 2024-02-20
@lanitochka17 lanitochka17 added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jan 30, 2024
@melvin-bot melvin-bot bot changed the title Expense - App auto-redirects to expense report from main chat after returning online [$500] Expense - App auto-redirects to expense report from main chat after returning online Jan 30, 2024
Copy link

melvin-bot bot commented Jan 30, 2024

Job added to Upwork: https://www.upwork.com/jobs/~017a5665dbb6dad48c

Copy link

melvin-bot bot commented Jan 30, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 30, 2024
Copy link

melvin-bot bot commented Jan 30, 2024

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

@lanitochka17
Copy link
Author

We think that this bug might be related to #wave5.
CC @dylanexpensify

@ZhenjaHorbach
Copy link
Contributor

Proposal

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

Expense - App auto-redirects to expense report from main chat after returning online

What is the root cause of that problem?

The main problem with the issue is that when we navigate back we save the previous screen in the route and since we have some useEffects related with navigation

useEffect(() => {
// We don't want this effect to run on the first render.
if (firstRenderRef.current) {
firstRenderRef.current = false;
return;
}
const onyxReportID = report.reportID;
const prevOnyxReportID = prevReport.reportID;
const routeReportID = getReportID(route);
// Navigate to the Concierge chat if the room was removed from another device (e.g. user leaving a room or removed from a room)
if (
// non-optimistic case
(!prevUserLeavingStatus && userLeavingStatus) ||
// optimistic case
(prevOnyxReportID &&
prevOnyxReportID === routeReportID &&
!onyxReportID &&
prevReport.statusNum === CONST.REPORT.STATUS_NUM.OPEN &&
(report.statusNum === CONST.REPORT.STATUS_NUM.CLOSED || (!report.statusNum && !prevReport.parentReportID && prevReport.chatType === CONST.REPORT.CHAT_TYPE.POLICY_ROOM))) ||
((ReportUtils.isMoneyRequest(prevReport) || ReportUtils.isMoneyRequestReport(prevReport)) && _.isEmpty(report))
) {
Navigation.dismissModal();
if (Navigation.getTopmostReportId() === prevOnyxReportID) {
Navigation.setShouldPopAllStateOnUP();
Navigation.goBack(ROUTES.HOME, false, true);
}
if (prevReport.parentReportID) {
// Prevent navigation to the Money Request Report if it is pending deletion.
const parentReport = ReportUtils.getReport(prevReport.parentReportID);
if (ReportUtils.isMoneyRequestReportPendingDeletion(parentReport)) {
return;
}
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(prevReport.parentReportID));
return;
}
Report.navigateToConciergeChat();
return;
}
// If you already have a report open and are deeplinking to a new report on native,
// the ReportScreen never actually unmounts and the reportID in the route also doesn't change.
// Therefore, we need to compare if the existing reportID is the same as the one in the route
// before deciding that we shouldn't call OpenReport.
if (onyxReportID === prevReport.reportID && (!onyxReportID || onyxReportID === routeReportID)) {
return;
}
fetchReportIfNeeded();
ComposerActions.setShouldShowComposeInput(true);
}, [
route,
report,
errors,
fetchReportIfNeeded,
prevReport.reportID,
prevUserLeavingStatus,
userLeavingStatus,
prevReport.statusNum,
prevReport.parentReportID,
prevReport.chatType,
prevReport,
]);

We call one of them from the previous screen and navigate to Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(prevReport.parentReportID));

Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(prevReport.parentReportID));

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

Because this behavior is not normal, that we are calling useEffect from another screen
I suggest limiting this useEffect and making it only valid when this screen is in focus

And add

        if (!isFocused) {
            return;
        }

What alternative solutions did you explore? (Optional)

NA

@dukenv0307
Copy link
Contributor

dukenv0307 commented Jan 31, 2024

Proposal

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

  • Expense - App auto-redirects to expense report from main chat after returning online

What is the root cause of that problem?

  • When creating request money in offline, we generate a optimistic report. Then, go online, that optimistic report is set to null
  • And in report screen, we have logic that will navigate user to the parent report if the current report is empty:
    ((ReportUtils.isMoneyRequest(prevReport) || ReportUtils.isMoneyRequestReport(prevReport)) && _.isEmpty(report))
    ) {
    Navigation.dismissModal();
    if (Navigation.getTopmostReportId() === prevOnyxReportID) {
    Navigation.setShouldPopAllStateOnUP();
    Navigation.goBack(ROUTES.HOME, false, true);
    }
    if (prevReport.parentReportID) {
    // Prevent navigation to the Money Request Report if it is pending deletion.
    const parentReport = ReportUtils.getReport(prevReport.parentReportID);
    if (ReportUtils.isMoneyRequestReportPendingDeletion(parentReport)) {
    return;
    }
    Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(prevReport.parentReportID));
    return;
    }
  • That leads to the current behavior.

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

What alternative solutions did you explore? (Optional)

  • NA

@laurenreidexpensify
Copy link
Contributor

@rushatgabhane bump for review

@melvin-bot melvin-bot bot added the Overdue label Feb 5, 2024
@laurenreidexpensify
Copy link
Contributor

@rushatgabhane bump ^^

@melvin-bot melvin-bot bot removed the Overdue label Feb 5, 2024
@rushatgabhane
Copy link
Member

rushatgabhane commented Feb 5, 2024

🎀👀🎀 i like @dukenv0307's proposal because it fixes the root cause

#35433 (comment)

Copy link

melvin-bot bot commented Feb 5, 2024

Triggered auto assignment to @iwiznia, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

Copy link

melvin-bot bot commented Feb 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 melvin-bot bot added the Overdue label Feb 7, 2024
@laurenreidexpensify
Copy link
Contributor

@iwiznia pls assign issue to @dukenv0307 if you agree thanks

Copy link

melvin-bot bot commented Feb 8, 2024

@iwiznia, @rushatgabhane, @laurenreidexpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

@iwiznia
Copy link
Contributor

iwiznia commented Feb 8, 2024

Add prevReport.isOptimisticReport to this condition

What exactly do you mean by that? Add it how? I assume as || isOptimisticReport?
Also, wouldn't that mean that the URL would be wrong if the backend returns a different reportID than the optimistic one?

@melvin-bot melvin-bot bot removed the Overdue label Feb 8, 2024
@dukenv0307
Copy link
Contributor

@iwiznia I mean that we should update the condition below:

if (ReportUtils.isMoneyRequestReportPendingDeletion(parentReport)) {

to:

                if (ReportUtils.isMoneyRequestReportPendingDeletion(parentReport) || prevReport.isOptimisticReport) {

@dukenv0307
Copy link
Contributor

Also, wouldn't that mean that the URL would be wrong if the backend returns a different reportID than the optimistic one?

Maybe I misunderstand your question. Pls help give me more details

@melvin-bot melvin-bot bot added the Overdue label Feb 12, 2024
Copy link

melvin-bot bot commented Feb 12, 2024

@iwiznia, @rushatgabhane, @laurenreidexpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

Copy link

melvin-bot bot commented Feb 13, 2024

@iwiznia @rushatgabhane @laurenreidexpensify this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

Copy link

melvin-bot bot commented Feb 13, 2024

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

@laurenreidexpensify
Copy link
Contributor

@iwiznia bump ^^

Copy link

melvin-bot bot commented Feb 14, 2024

@iwiznia, @rushatgabhane, @laurenreidexpensify Huh... This is 4 days overdue. Who can take care of this?

Copy link

melvin-bot bot commented Feb 16, 2024

@iwiznia, @rushatgabhane, @laurenreidexpensify Still overdue 6 days?! Let's take care of this!

@laurenreidexpensify
Copy link
Contributor

@iwiznia bump ^^

@iwiznia
Copy link
Contributor

iwiznia commented Feb 19, 2024

Sorry for the radio silence, last week I realized I had a bad email filter and this (among a few other issues) got filtered out by mistake.

Maybe I misunderstand your question. Pls help give me more details

So we will exit here if it is an optimistic report, right? Doesn't that mean it would not open the correct report when clicked, given it would return early and not redirect anywhere?

@melvin-bot melvin-bot bot removed the Overdue label Feb 19, 2024
@dukenv0307
Copy link
Contributor

So we will exit here if it is an optimistic report, right?

Yes

Doesn't that mean it would not open the correct report when clicked

When we clicked to open the report directly, it did not redirect anywhere because the condition here return false

Copy link

melvin-bot bot commented Feb 20, 2024

@iwiznia @rushatgabhane @laurenreidexpensify this issue is now 3 weeks old. There is one more week left before this issue breaks WAQ and will need to go internal. What needs to happen to get a PR in review this week? Please create a thread in #expensify-open-source to discuss. Thanks!

Copy link

melvin-bot bot commented Feb 20, 2024

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

@iwiznia
Copy link
Contributor

iwiznia commented Feb 20, 2024

When we clicked to open the report directly, it did not redirect anywhere because the condition here return false

Isn't this incorrect? We should be opening the report, no?

@dukenv0307
Copy link
Contributor

Isn't this incorrect? We should be opening the report, no?

Oh, I mean that it is not redirected to another report if we open the report directly

@mvtglobally
Copy link

Issue not reproducible during KI retests. (First week)

@laurenreidexpensify
Copy link
Contributor

Am closing based on this not being reproducible in this week's testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

7 participants