Skip to content

[$500] Chat-Infinite loading occurs if conversation ID is edited to 0 #32651

Closed

Description

@izarutskaya

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.9-0
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. Login to ND Expensify
  2. On the URL change the conversation ID to 0 (https://staging.new.expensify.com/r/0)
  3. Verify you briefly see the skeleton loader
  4. Verify you see a "You don't have access to this chat" message in the conversation history

Expected Result:

"You don't have access to this chat" message in the conversation history is shown

Actual Result:

Infinite skeleton loader occurs if conversation ID is edited to 0 in the URL
Note: The issue reproduces for only "0" value

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

Bug6304320_1701946093585.2023-12-07_11-02-22.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~015ee46823d25664a9
  • Upwork Job ID: 1732725262675222528
  • Last Price Increase: 2023-12-07
  • Automatic offers:
    • alitoshmatov | Reviewer | 28066316
    • bernhardoj | Contributor | 28066317

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Dec 7, 2023
  2. changed the title [-]Chat-Infinite loading occurs if conversation ID is edited to 0[/-] [+][$500] Chat-Infinite loading occurs if conversation ID is edited to 0[/+] on Dec 7, 2023
  3. melvin-bot commented on Dec 7, 2023

    @melvin-bot
  4. melvin-bot commented on Dec 7, 2023

    @melvin-bot

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

  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Dec 7, 2023
  6. melvin-bot commented on Dec 7, 2023

    @melvin-bot

    Bug0 Triage Checklist (Main S/O)

    • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
    • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
      • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
    • This bug is reproducible using the reproduction steps in the OP. S/O
      • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
      • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
    • This issue is filled out as thoroughly and clearly as possible
      • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
    • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync
  7. melvin-bot commented on Dec 7, 2023

    @melvin-bot

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

  8. dukenv0307 commented on Dec 7, 2023

    @dukenv0307
    Contributor

    Proposal

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

    Infinite loading occurs if conversation ID is edited to 0

    What is the root cause of that problem?

    When the reportID is 0, we don't call openReport API and isLoadingInitialReportActions is true by default prop. So infinite loading occurs

    if (!ReportUtils.isValidReportIDFromPath(reportIDFromPath)) {

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

    We should check if isLoadingInitialReportActions but reportID is invalid we will not show loading page. Instead, we will show not found page by create a variable like isValidReportIDFromPath

    isValidReportIDFromPath = ReportUtils.isValidReportIDFromPath(reportIDFromPath)
    // If has no reportID in param, it means we are setting reportID in `ReportScreenIDSetter`
    const hasReportIDFromParam = !!route.params.reportID;
    

    And then update the condition to show not found page with this variable.

    const shouldShowNotFoundPage = useMemo(
        () => (!firstRenderRef.current && ((!report.reportID && !isOptimisticDelete && !reportMetadata.isLoadingInitialReportActions && !isLoading && !userLeavingStatus) || (!isValidReportIDFromPath && hasReportIDFromParam))) || shouldHideReport,
        [report, reportMetadata, isLoading, shouldHideReport, isOptimisticDelete, userLeavingStatus],
    );
    

    What alternative solutions did you explore? (Optional)

    NA

    Result

    Screen.Recording.2023-12-14.at.12.47.00.mov
    Screen.Recording.2023-12-14.at.12.47.48.mov
  9. mkhutornyi commented on Dec 7, 2023

    @mkhutornyi
    Contributor

    Proposal

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

    Infinite loading occurs occurs if reportID = 0

    What is the root cause of that problem?

    We validate reportID here and early return if invalid before calling OpenReport which sets isLoadingInitialReportActions to false optimistically.
    So reportMetadata_0 is not set in Onyx and it fallback to this default object:

    reportMetadata: {
    isLoadingInitialReportActions: true,
    isLoadingOlderReportActions: false,
    isLoadingNewerReportActions: false,
    },

    So isLoadingInitialReportActions is true and it doesn't meet shouldShowNotFoundPage condition

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

    1. define new flag. Let's say X!
      X = ReportUtils.isValidReportIDFromPath(reportID) && reportMetadata.isLoadingInitialReportActions
      And replace all reportMetadata.isLoadingInitialReportActions occurrences with X in ReportScreen.js component

    2. (optional) For existing users who already have stale reportMetadata_reportID in Onyx:
      clear reportMetadata_reportID before early return here:

      if (!ReportUtils.isValidReportIDFromPath(reportIDFromPath)) {
      return;
      }

    so call this function:

    function clearReportMetadata(reportID: string) {
        Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, null);
    }
    
  10. yh-0218 commented on Dec 7, 2023

    @yh-0218
    Contributor

    Proposal

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

    Infinite loading occurs occurs if reportID = 0

    What is the root cause of that problem?

    We didn't consider isValidReportIDFromPath to get shouldShowNotFoundPage

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

    We need to consider isValidReportIDFromPath to get shouldShowNotFoundPage

    const shouldShowNotFoundPage = useMemo(
            () => {
                const reportIDFromPath = getReportID(route);
                if (['0'].includes(reportIDFromPath)) {
                    return true;
                }
                return (!firstRenderRef.current && !report.reportID && !isOptimisticDelete && !reportMetadata.isLoadingInitialReportActions && !isLoading && !userLeavingStatus) || shouldHideReport;
            },
            [route, report.reportID, isOptimisticDelete, reportMetadata.isLoadingInitialReportActions, isLoading, userLeavingStatus, shouldHideReport],
        );
    

    What alternative solutions did you explore? (Optional)

    Screen.Recording.2023-12-07.at.2.59.55.PM.mov
  11. bernhardoj commented on Dec 7, 2023

    @bernhardoj
    Contributor

    Proposal

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

    When visiting a report with id of 0, the loading shows infinitely.

    What is the root cause of that problem?

    We currently prevent the open report API if the report id is 0, empty, or "null" string. This makes the report screen always show the skeleton loader.

    // Report ID will be empty when the reports collection is empty.
    // This could happen when we are loading the collection for the first time after logging in.
    if (!ReportUtils.isValidReportIDFromPath(reportIDFromPath)) {
    return;
    }

    App/src/libs/ReportUtils.ts

    Lines 3915 to 3917 in 8fa65ec

    function isValidReportIDFromPath(reportIDFromPath: string): boolean {
    return !['', 'null', '0'].includes(reportIDFromPath);
    }

    This is added to fix this issue where the app crashes if we send a "null" string as the report ID to the API, but I found it weird why it only happens with a "null" string and not other string such as "a". So, I'm trying to reproduce the issue without the fix above and it works fine (it's probably a temp BE issue).

    So, currently, if we visit a report with an ID of 0 or null, the loading shows indefinitely, but visiting a report with an ID of other characters such as "a", the not found page will show, so it's a bit inconsistent with how we handle the report ID.

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

    I would suggest removing isValidReportIDFromPath. Let the BE handles any report ID we sent and the not found page will be shown if it's not found in the BE.

    if (!reportIDFromPath) {
        return;
    }
    

    What alternative solutions did you explore? (Optional)

    Show the not found page if the report id is not empty and is invalid.

    // add to shouldShowNotFoundPage condition
    const reportIDParams = lodashGet(route.params, 'reportID');
    || (reportIDParams && !ReportUtils.isValidReportIDFromPath(reportIDParams))
    
  12. 52 remaining items

  13. alitoshmatov commented on Feb 5, 2024

    @alitoshmatov
    Contributor

    @abekkala Since @neil-marcellini is not responding, can we get another internal engineer to take a look at this?

  14. abekkala commented on Feb 5, 2024

    @abekkala
    Contributor

    I've reached out to @neil-marcellini

  15. neil-marcellini commented on Feb 5, 2024

    @neil-marcellini
    Contributor

    Sorry for not seeing this earlier, and thanks April for DMing me on NewDot. That's the best way to reach me. I haven't been checking my GH mentions since there are too many, however, I will start checking them daily so I don't miss things like this again.

    Show the not found page if the report id is not empty and is invalid.

    @alitoshmatov Ok I see, thanks for explaining. I'm happy with this, and I approve the alternate solution from @bernhardoj's proposal. Please continue with the PR and request my review after the C+ approves.

  16. melvin-bot commented on Feb 13, 2024

    @melvin-bot

    @abekkala, @neil-marcellini, @bernhardoj, @alitoshmatov Whoops! This issue is 2 days overdue. Let's get this updated quick!

  17. abekkala commented on Feb 13, 2024

    @abekkala
    Contributor

    @bernhardoj do you have a PR up for this?

  18. bernhardoj commented on Feb 13, 2024

    @bernhardoj
    Contributor

    Yes, it was merged yesterday #33394

  19. abekkala commented on Feb 15, 2024

    @abekkala
    Contributor

    deployed to prod Feb 14

  20. melvin-bot commented on Feb 23, 2024

    @melvin-bot

    @abekkala, @neil-marcellini, @bernhardoj, @alitoshmatov Whoops! This issue is 2 days overdue. Let's get this updated quick!

  21. abekkala commented on Feb 23, 2024

    @abekkala
    Contributor

    7 day waiting period end has ended - no regressions

    Fix: @bernhardoj [$500] Offer link
    PR Review: @alitoshmatov [$500] Offer link

  22. abekkala commented on Feb 23, 2024

    @abekkala
    Contributor

    @bernhardoj and @alitoshmatov Upwork payments sent and contracts ended - thank you! 🎉

  23. melvin-bot commented on Mar 25, 2024

    @melvin-bot

    ⚠️ Looks like this issue was linked to a Deploy Blocker here

    If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

    If a regression has occurred and you are the assigned CM follow the instructions here.

    If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in reviewWeeklyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions