Skip to content

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

Closed

Description

@lanitochka17

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

Activity

  1. added
    External
    Daily
    Bug
    on Jan 30, 2024
  2. 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[/+] on Jan 30, 2024
  3. melvin-bot commented on Jan 30, 2024

    @melvin-bot
  4. melvin-bot commented on Jan 30, 2024

    @melvin-bot

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

  5. added
    Help Wanted
    on Jan 30, 2024
  6. melvin-bot commented on Jan 30, 2024

    @melvin-bot

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

  7. lanitochka17 commented on Jan 30, 2024

    @lanitochka17
    Author

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

  8. ZhenjaHorbach commented on Jan 30, 2024

    @ZhenjaHorbach
    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

  9. dukenv0307 commented on Jan 31, 2024

    @dukenv0307
    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?

    • 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
  10. laurenreidexpensify commented on Feb 2, 2024

    @laurenreidexpensify
    Contributor

    @rushatgabhane bump for review

  11. 17 remaining items

  12. laurenreidexpensify commented on Feb 14, 2024

    @laurenreidexpensify
    Contributor

    @iwiznia bump ^^

  13. melvin-bot commented on Feb 14, 2024

    @melvin-bot

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

  14. melvin-bot commented on Feb 16, 2024

    @melvin-bot

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

  15. laurenreidexpensify commented on Feb 19, 2024

    @laurenreidexpensify
    Contributor

    @iwiznia bump ^^

  16. iwiznia commented on Feb 19, 2024

    @iwiznia
    Contributor

    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?

  17. dukenv0307 commented on Feb 20, 2024

    @dukenv0307
    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

  18. melvin-bot commented on Feb 20, 2024

    @melvin-bot

    @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!

  19. melvin-bot commented on Feb 20, 2024

    @melvin-bot

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

  20. iwiznia commented on Feb 20, 2024

    @iwiznia
    Contributor

    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?

  21. dukenv0307 commented on Feb 20, 2024

    @dukenv0307
    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

  22. mvtglobally commented on Feb 21, 2024

    @mvtglobally

    Issue not reproducible during KI retests. (First week)

  23. laurenreidexpensify commented on Feb 21, 2024

    @laurenreidexpensify
    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

Metadata

Metadata

Labels

BugDailyEngineeringExternalHelp Wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions