Skip to content

[HOLD for payment 2024-08-09] [$250] Threads - Leaving from multilevel threads navigates to wrong thread #46085

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: 9.0.11-0
Reproducible in staging?: Y
Reproducible in production?: N
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): bezawitgebremichael+kkii@gmail.com
Issue reported by: Applause - Internal Team

Action Performed:

  1. Navigate to staging.new.expensify.com
  2. Open a chat
  3. Send a message (Name it parent message for easier observation)
  4. Hover over the message and click on reply in thread
  5. Send another message in the thread (Name it thread 1 for easier observation)
  6. Hover over the message and click on reply in thread
  7. Send another message in the thread (Name it thread 2 for easier observation)
  8. Click on the header of the thread
  9. Click on leave
  10. Note the name of the header and click on it
  11. Click on leave
  12. Note the name of the header and wait a few seconds

Expected Result:

When leaving the first level thread app navigates user to the parent thread, when leaving from the parent thread app navigates to the Original chat and no "You don't have access to this chat" page is displayed

Actual Result:

When leaving the first level thread app navigates to the parent thread but when leaving the parent thread again the app navigates user back to the first level thread and then after a few seconds "You don't have access to this chat" page is displayed

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

Bug6550339_1721722658336.bandicam_2024-07-23_11-02-57-895.mp4

405

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01a17100bfa3035f8c
  • Upwork Job ID: 1816165199632115677
  • Last Price Increase: 2024-07-24
Issue OwnerCurrent Issue Owner: @mananjadhav

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    DeployBlockerIndicates it should block deploying the API
    on Jul 23, 2024
  2. melvin-bot commented on Jul 23, 2024

    @melvin-bot

    Triggered auto assignment to @marcaaron (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  3. github-actions commented on Jul 23, 2024

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  4. lanitochka17 commented on Jul 23, 2024

    @lanitochka17
    Author

    We think that this bug might be related to #vip-vsp

  5. nyomanjyotisa commented on Jul 24, 2024

    @nyomanjyotisa
    Member

    Proposal

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

    Leaving from multilevel threads navigates to wrong thread

    What is the root cause of that problem?

    On leave action we always navigate to the most recent report/the last accessed report here

    navigateToMostRecentReport(report);

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

    If parentReportID exist navigate to the parent report instead of the most recent report

        if (report.parentReportID) {
            const parentReportRoute = ROUTES.REPORT_WITH_ID.getRoute(report.parentReportID);
            Navigation.goBack(parentReportRoute);
        }else{
            navigateToMostRecentReport(report);
        }
    

    What alternative solutions did you explore? (Optional)

  6. daledah commented on Jul 24, 2024

    @daledah
    Contributor

    Proposal

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

    When leaving the first level thread app navigates to the parent thread but when leaving the parent thread again the app navigates user back to the first level thread and then after a few seconds "You don't have access to this chat" page is displayed

    What is the root cause of that problem?

    When leaving room, we always call:

    navigateToMostRecentReport(report);

    That function get the most recent access report based on:

    App/src/libs/ReportUtils.ts

    Lines 1209 to 1214 in 2bb1d00

    function getMostRecentlyVisitedReport(reports: Array<OnyxEntry<Report>>, reportMetadata: OnyxCollection<ReportMetadata>): OnyxEntry<Report> {
    const filteredReports = reports.filter(
    (report) => !!report?.reportID && !!(reportMetadata?.[`${ONYXKEYS.COLLECTION.REPORT_METADATA}${report.reportID}`]?.lastVisitTime ?? report?.lastReadTime),
    );
    return lodashMaxBy(filteredReports, (a) => new Date(reportMetadata?.[`${ONYXKEYS.COLLECTION.REPORT_METADATA}${a?.reportID}`]?.lastVisitTime ?? a?.lastReadTime ?? '').valueOf());
    }

    without filtering the leaved thread, lead to the loop behavior: Assume we have two thread 1 and 2. Access 1 then access 2. Now leave thread 2. User is moved to thread 1. Then leave thread 1. User is moved to thread 2. And then join thread 2. Then leave thread 2. User is moved to thread 1, ...

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

    We should filter the leaved report from above:

    function getMostRecentlyVisitedReport(reports: Array<OnyxEntry<Report>>, reportMetadata: OnyxCollection<ReportMetadata>, shouldKeepLeavedThread = true): OnyxEntry<Report> {
        const filteredReports = reports.filter((report) => {
            const shouldKeep = shouldKeepLeavedThread || !isChatThread(report) || (isChatThread(report) && report?.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN);
            return shouldKeep && !!report?.reportID && !!(reportMetadata?.[`${ONYXKEYS.COLLECTION.REPORT_METADATA}${report.reportID}`]?.lastVisitTime ?? report?.lastReadTime);
        });
        return lodashMaxBy(filteredReports, (a) => new Date(reportMetadata?.[`${ONYXKEYS.COLLECTION.REPORT_METADATA}${a?.reportID}`]?.lastVisitTime ?? a?.lastReadTime ?? '').valueOf());
    }
    

    When leaving room, we use shouldKeepLeavedThread : false to make sure this change does not break other logic.

  7. francoisl commented on Jul 24, 2024

    @francoisl
    Contributor

    Thanks for the proposals. Can you identify which PR from the checklist introduced this issue?

  8. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 24, 2024
  9. melvin-bot commented on Jul 24, 2024

    @melvin-bot
  10. changed the title [-] Threads - Leaving from multilevel threads navigates to wrong thread[/-] [+][$250] Threads - Leaving from multilevel threads navigates to wrong thread[/+] on Jul 24, 2024
  11. 37 remaining items

  12. allroundexperts commented on Aug 12, 2024

    @allroundexperts
    Contributor

    Checklist

    1. https://github.com/Expensify/App/pull/44948/files
    2. https://github.com/Expensify/App/pull/44948/files#r1713856786
    3. N/A
    4. A regression test would be helpful.

    Regression Test

    1. Navigate to the app and Open a chat
    2. Send a message (Name it parent message for easier observation)
    3. Hover over the message and click on reply in thread
    4. Send another message in the thread (Name it thread 1 for easier observation)
    5. Hover over the message and click on reply in thread
    6. Send another message in the thread (Name it thread 2 for easier observation)
    7. Click on the header of the thread and click on leave
    8. Note the name of the header and click on it, and click on leave

    Verify that when leaving the first level thread app navigates user to the parent thread, when leaving from the parent thread app navigates to the Original chat and no "You don't have access to this chat" page is displayed

    Do we 👍 or 👎 ?

  13. adelekennedy commented on Aug 14, 2024

    @adelekennedy
    Contributor

    Payouts due:

    Upwork job is here.

  14. adelekennedy commented on Aug 15, 2024

    @adelekennedy
    Contributor

    Bump @daledah!

  15. daledah commented on Aug 16, 2024

    @daledah
    Contributor

    Sorry @adelekennedy I don't have any Upwork Connects so I could not apply to the job. Instead, could you send the offer directly to my profile here https://www.upwork.com/freelancers/~0138d999529f34d33f. TY

  16. melvin-bot commented on Aug 20, 2024

    @melvin-bot

    @allroundexperts, @marcaaron, @adelekennedy, @daledah Whoops! This issue is 2 days overdue. Let's get this updated quick!

  17. adelekennedy commented on Aug 21, 2024

    @adelekennedy
    Contributor

    hired @daledah!

  18. daledah commented on Aug 21, 2024

    @daledah
    Contributor

    @adelekennedy I have accepted, thank you

  19. JmillsExpensify commented on Oct 8, 2024

    @JmillsExpensify
    Contributor

    $250 approved for @allroundexperts

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionDailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions