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-08-09] [$250] Threads - Leaving from multilevel threads navigates to wrong thread #46085

Closed
1 of 6 tasks
lanitochka17 opened this issue Jul 23, 2024 · 28 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@lanitochka17
Copy link

lanitochka17 commented Jul 23, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] 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): [email protected]
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
@lanitochka17 lanitochka17 added DeployBlockerCash This issue or pull request should block deployment DeployBlocker Indicates it should block deploying the API labels Jul 23, 2024
Copy link

melvin-bot bot commented Jul 23, 2024

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

Copy link
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.

@lanitochka17
Copy link
Author

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

@nyomanjyotisa
Copy link
Contributor

nyomanjyotisa commented Jul 24, 2024

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)

@marcaaron marcaaron removed the DeployBlocker Indicates it should block deploying the API label Jul 24, 2024
@daledah
Copy link
Contributor

daledah commented Jul 24, 2024

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.

@francoisl
Copy link
Contributor

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

@francoisl francoisl added the External Added to denote the issue can be worked on by a contributor label Jul 24, 2024
Copy link

melvin-bot bot commented Jul 24, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01a17100bfa3035f8c

@melvin-bot melvin-bot bot changed the title Threads - Leaving from multilevel threads navigates to wrong thread [$250] Threads - Leaving from multilevel threads navigates to wrong thread Jul 24, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 24, 2024
Copy link

melvin-bot bot commented Jul 24, 2024

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

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 24, 2024
@francoisl francoisl added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 24, 2024
@allroundexperts
Copy link
Contributor

Thanks for the proposals everyone!

@daledah's proposal has the correct RCA and fixes the root issue.

@nyomanjyotisa I think your proposal is applying a cosmetic patch, without addressing the actual underlying issue.

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Jul 24, 2024

Current assignee @marcaaron is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 24, 2024
Copy link

melvin-bot bot commented Jul 24, 2024

📣 @daledah You have been assigned to this job!
Please apply to the Upwork job and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Once you apply to this job, your Upwork ID will be stored and you will be automatically hired for future jobs!
Keep in mind: Code of Conduct | Contributing 📖

@francoisl
Copy link
Contributor

@daledah are you available to submit a PR?

@francoisl
Copy link
Contributor

We had an issue with the web production deploy that caused the deploy to fail for a few days, but it's fixed now and this issue is now reproducible on production. Going to remove the deploy blocker.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Aug 2, 2024
@melvin-bot melvin-bot bot changed the title [$250] Threads - Leaving from multilevel threads navigates to wrong thread [HOLD for payment 2024-08-09] [$250] Threads - Leaving from multilevel threads navigates to wrong thread Aug 2, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Aug 2, 2024
Copy link

melvin-bot bot commented Aug 2, 2024

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

Copy link

melvin-bot bot commented Aug 2, 2024

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

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

  • @allroundexperts requires payment through NewDot Manual Requests
  • @daledah requires payment (Needs manual offer from BZ)

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Aug 8, 2024
Copy link

melvin-bot bot commented Aug 9, 2024

Issue is ready for payment but no BZ is assigned. @adelekennedy you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks!

@melvin-bot melvin-bot bot removed the Overdue label Aug 9, 2024
Copy link

melvin-bot bot commented Aug 9, 2024

Payment Summary

Upwork Job

BugZero Checklist (@adelekennedy)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1816165199632115677/hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@allroundexperts
Copy link
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 👎 ?

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Aug 12, 2024
@adelekennedy
Copy link

adelekennedy commented Aug 14, 2024

Payouts due:

Upwork job is here.

@melvin-bot melvin-bot bot removed the Overdue label Aug 14, 2024
@adelekennedy
Copy link

Bump @daledah!

@daledah
Copy link
Contributor

daledah commented Aug 16, 2024

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

@melvin-bot melvin-bot bot added the Overdue label Aug 19, 2024
Copy link

melvin-bot bot commented Aug 20, 2024

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

@adelekennedy
Copy link

hired @daledah!

@melvin-bot melvin-bot bot removed the Overdue label Aug 21, 2024
@daledah
Copy link
Contributor

daledah commented Aug 21, 2024

@adelekennedy I have accepted, thank you

@JmillsExpensify
Copy link

$250 approved for @allroundexperts

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 Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

9 participants