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-02-07] [$500] Thread - "Join" button appear when user Leave thread #34820

Closed
2 of 6 tasks
lanitochka17 opened this issue Jan 19, 2024 · 31 comments
Closed
2 of 6 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@lanitochka17
Copy link

lanitochka17 commented Jan 19, 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: 1.4.28-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. Navigate to a conversation
  2. Start a thread and send some messages
  3. Click on the three dot menu and hit "Leave thread"

Expected Result:

User should navigate back to the parent conversation with no visual issues

Actual Result:

"Join" button appear when user Leave thread

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

Bug6347846_1705683544658.az_recorder_20240119_170154.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~012a09bc563f2546c1
  • Upwork Job ID: 1748398010896543744
  • Last Price Increase: 2024-01-19
  • Automatic offers:
    • s77rt | Reviewer | 28120092
    • DylanDylann | Contributor | 28120093
@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 19, 2024
Copy link

melvin-bot bot commented Jan 19, 2024

Job added to Upwork: https://www.upwork.com/jobs/~012a09bc563f2546c1

@melvin-bot melvin-bot bot changed the title Thread - "Join" button appear when user Leave thread [$500] Thread - "Join" button appear when user Leave thread Jan 19, 2024
Copy link

melvin-bot bot commented Jan 19, 2024

Triggered auto assignment to @lschurr (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 19, 2024
Copy link

melvin-bot bot commented Jan 19, 2024

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

@lanitochka17
Copy link
Author

We think that this bug might be related to #vip-vsb.
CC @quinthar

@ishpaul777
Copy link
Contributor

Proposal

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

"Join" button appear when user Leave thread

What is the root cause of that problem?

Below are the conditions that need to be met to show the join button, technically when user click leave thread all conditions meet and join button appears while we are navigating the user to the parent chat.

const canJoin = canJoinOrLeave && !isWhisperAction && props.report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN;
const canLeave = canJoinOrLeave && ((isChatThread && props.report.notificationPreference.length) || isUserCreatedPolicyRoom || canLeaveRoom);

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

We need to check if navigation is in progress, we can use useIsFocused hook to check if screen is focused, so join is not visible until user is redirected to the parent chat

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

@abzokhattab
Copy link
Contributor

abzokhattab commented Jan 19, 2024

Proposal

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

"Join" button appear when user Leave thread

What is the root cause of that problem?

when leaving a room we change the reportID optimistically to null

reportID: null,

and the join button is shown based on this condition:

const canJoinOrLeave = (isChatThread && !isEmptyChat) || isUserCreatedPolicyRoom || canLeaveRoom;
const canJoin = canJoinOrLeave && !isWhisperAction && props.report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN;

so when leaving a thread the isThreadChat falsely returns true while transitioning resulting in showing the join button.

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

we can pass the isReportReadyForDisplay from the ReportScreen component as a prop with default value as false then update the condition that is responsible for showing the header tooltip:

{canJoin && !isSmallScreenWidth && joinButton}

to:

{canJoin && !isSmallScreenWidth && joinButton && props.isReportReadyForDisplay}

alternativly

we can fix the isThreadChat function since it shouldn't return true for a report the user left, to fix it we need to fix the underlying isThread
function to check if the current reportID exits:

    return Boolean(report?.reportID && report?.parentReportID && report?.parentReportActionID);

@paultsimura
Copy link
Contributor

paultsimura commented Jan 19, 2024

Proposal

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

The navigation on leaving Thread is delayed

What is the root cause of that problem?

First of all, I'd like to stress out that the issue is not only with the "Join" button but with the skeleton view as well.
This is happening because we do not explicitly pass the navigation command on leaving the thread in Report.leaveRoom() as opposed to the leaving room:

App/src/libs/actions/Report.ts

Lines 2169 to 2177 in 56fb814

if (isWorkspaceMemberLeavingWorkspaceRoom) {
const participantAccountIDs = PersonalDetailsUtils.getAccountIDsByLogins([CONST.EMAIL.CONCIERGE]);
const chat = ReportUtils.getChatByParticipants(participantAccountIDs);
if (chat?.reportID) {
// We should call Navigation.goBack to pop the current route first before navigating to Concierge.
Navigation.goBack(ROUTES.HOME);
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(chat.reportID));
}
}

We wait until it's removed from Onyx, and then the user gets navigated automatically because the thread report no longer exists. And this moment between the report being deleted and the user being navigated is causing the behavior in this issue.

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

We need to explicitly navigate the user to the parent report upon leaving the thread:

if (isChatThread(report)) {
    Navigation.goBack(ROUTES.HOME);
    Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.parentReportID));
} else if (isWorkspaceMemberLeavingWorkspaceRoom) {
        const participantAccountIDs = PersonalDetailsUtils.getAccountIDsByLogins([CONST.EMAIL.CONCIERGE]);
        const chat = ReportUtils.getChatByParticipants(participantAccountIDs);
        if (chat?.reportID) {
            // We should call Navigation.goBack to pop the current route first before navigating to Concierge.
            Navigation.goBack(ROUTES.HOME);
            Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(chat.reportID));
        }
}

Result:

Screen.Recording.2024-01-19.at.19.00.15.mov

What alternative solutions did you explore? (Optional)

@DylanDylann
Copy link
Contributor

DylanDylann commented Jan 20, 2024

Dupe of #31220

@s77rt
Copy link
Contributor

s77rt commented Jan 20, 2024

@ishpaul777 Thanks for the proposal. Your RCA makes sense however the solution is a workaround. I don't see how the screen being focused or not should control the visibility of the join/leave buttons.

@s77rt
Copy link
Contributor

s77rt commented Jan 20, 2024

@abzokhattab Your proposal does not follow the template, it's incomplete (missing a clear RCA).

@s77rt
Copy link
Contributor

s77rt commented Jan 20, 2024

@paultsimura Thanks for the proposal. Regarding your RCA:

This is happening because we do not explicitly pass the navigation command on leaving the thread

This is not exactly true. The bug can be reproduced whether we navigate explicitly or not. This is because both navigation and Onyx updates are async. Doing one after the other does not guarantee any order.

@s77rt
Copy link
Contributor

s77rt commented Jan 20, 2024

@DylanDylann I agree this could have been handled in the linked issue. I checked your proposal. The RCA is correct. The suggested solution does not fix the problem but the alternative solution does. Except that we should check the existence of the report id instead of the "emptiness" of the report. This is because optimistically the report would still be there.

Please update/copy the proposal from other issue and tag me once done

@abzokhattab
Copy link
Contributor

abzokhattab commented Jan 21, 2024

@s77rt Thank you, yeah you are correct i forgot to add the RCA, I have updated the RCA and added a second solution that addresses fixing the isThread function which i believe is the actual root cause.

@DylanDylann
Copy link
Contributor

@s77rt I updated the proposal

@s77rt
Copy link
Contributor

s77rt commented Jan 21, 2024

@abzokhattab Thanks for the update. The RCA makes sense. As for the solution I don't think we should use isReportReadyForDisplay as we already have an inner variable (isLoading) for the loading state of the header. Also the isThread function is not necessary incorrect.

@s77rt
Copy link
Contributor

s77rt commented Jan 21, 2024

@DylanDylann Can you please post the proposal here

@DylanDylann
Copy link
Contributor

DylanDylann commented Jan 21, 2024

Proposal

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

  • Thread - "Join" button appear when user Leave thread

What is the root cause of that problem?

  • After clicking on "Leave thread", we set the optimistic data for this thread as below:

    App/src/libs/actions/Report.ts

    Lines 2103 to 2118 in 52adf77

    const optimisticData: OnyxUpdate[] = [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
    value: isWorkspaceMemberLeavingWorkspaceRoom
    ? {
    notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
    }
    : {
    reportID: null,
    stateNum: CONST.REPORT.STATE_NUM.APPROVED,
    statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
    notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
    },
    },
    ];
  • Then we use this useEffect to handle case onyxReportID: undefined | null. It will navigate the user to the previous report.
  • When the above useEffect executing, it will display the above optimistic report for a while, which leads to the bug

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

  • We can hide the Join button (and the HeaderView) once the report.reportID is empty as we did in other screens.
  • To hide the Join button, we can update:
    const canJoin = canJoinOrLeave && !isWhisperAction && props.report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN;

    to
   const canJoin = props.report.reportID && canJoinOrLeave && !isWhisperAction && props.report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN;
    const isLoading = !props.report.reportID || !props.report || !title;

What alternative solutions did you explore? (Optional)

  • NA

@DylanDylann
Copy link
Contributor

DylanDylann commented Jan 21, 2024

@s77rt I just add the alternative solution in here based on your comment here that the main solution does not work

@s77rt
Copy link
Contributor

s77rt commented Jan 22, 2024

@DylanDylann Thank you. Let's go with updating the isLoading variable to fix all the header content.

🎀 👀 🎀 C+ reviewed
Link to proposal

Copy link

melvin-bot bot commented Jan 22, 2024

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

@neil-marcellini
Copy link
Contributor

@DylanDylann Thank you. Let's go with updating the isLoading variable to fix all the header content.

🎀 👀 🎀 C+ reviewed Link to proposal

Looks pretty good. Please go ahead and get started.

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

melvin-bot bot commented Jan 24, 2024

📣 @s77rt 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Jan 24, 2024

📣 @DylanDylann 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Jan 25, 2024
@DylanDylann
Copy link
Contributor

@s77rt PR #35202 is ready to review

Copy link

melvin-bot bot commented Jan 31, 2024

⚠️ 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.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jan 31, 2024
@melvin-bot melvin-bot bot changed the title [$500] Thread - "Join" button appear when user Leave thread [HOLD for payment 2024-02-07] [$500] Thread - "Join" button appear when user Leave thread Jan 31, 2024
Copy link

melvin-bot bot commented Jan 31, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jan 31, 2024
Copy link

melvin-bot bot commented Jan 31, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.34-1 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-02-07. 🎊

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

Copy link

melvin-bot bot commented Jan 31, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@s77rt / @DylanDylann] The PR that introduced the bug has been identified. Link to the PR:
  • [@s77rt / @DylanDylann] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@s77rt / @DylanDylann] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@s77rt / @DylanDylann] Determine if we should create a regression test for this bug.
  • [@s77rt / @DylanDylann] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@lschurr] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@s77rt
Copy link
Contributor

s77rt commented Feb 2, 2024

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Feb 7, 2024
@lschurr
Copy link
Contributor

lschurr commented Feb 7, 2024

Payment summary:

@lschurr
Copy link
Contributor

lschurr commented Feb 7, 2024

This is complete.

@lschurr lschurr closed this as completed Feb 7, 2024
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 Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

8 participants