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-01-17] Unsubscribe icon shows up after leaving your own thread #30546

Closed
6 tasks
srikarparsi opened this issue Oct 27, 2023 · 36 comments
Closed
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 Engineering Internal Requires API changes or must be handled by Expensify staff

Comments

@srikarparsi
Copy link
Contributor

srikarparsi commented Oct 27, 2023

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.3.93-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:
Email or phone of affected tester (no customers): N/A
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: @srikarparsi and Applause
Slack conversation: N/A

Issue found when executing PR #27994

Action Performed:

Break down in numbered steps

  1. Comment on a report
  2. Reply to the comment
  3. Go into the thread, and then click leave thread
  4. Return to the parent report.
  5. The unsubscribe icon will show up even if the report is no longer shared.

Expected Result:

Describe what you think should've happened

The subscribe icon should show up

Actual Result:

Describe what actually happened

The unsubscribe icon shows up instead

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Yes

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

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2023-10-27.at.4.49.30.PM.mov
MacOS: Desktop

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~017a3500c3ff4829ca
  • Upwork Job ID: 1719512812572073984
  • Last Price Increase: 2023-11-01
@srikarparsi srikarparsi added the Daily KSv2 label Oct 27, 2023
@srikarparsi srikarparsi self-assigned this Oct 27, 2023
@paultsimura
Copy link
Contributor

paultsimura commented Oct 28, 2023

Proposal

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

The "Unsubscribe" context menu action is visible even after the thread was left.

What is the root cause of that problem?

The issue is that on leaving the thread, here:

} else if (props.report.notificationPreference.length) {
threeDotMenuItems.push({
icon: Expensicons.ChatBubbles,
text: props.translate('common.leaveThread'),
onSelected: Session.checkIfActionIsAllowed(() => Report.leaveRoom(props.report.reportID)),
});
}

We call this action:

App/src/libs/actions/Report.js

Lines 2011 to 2078 in a59d56f

/**
* Leave a report by setting the state to submitted and closed
*
* @param {String} reportID
* @param {Boolean} isWorkspaceMemberLeavingWorkspaceRoom
*/
function leaveRoom(reportID, isWorkspaceMemberLeavingWorkspaceRoom = false) {
const report = lodashGet(allReports, [reportID], {});
const reportKeys = _.keys(report);
// Pusher's leavingStatus should be sent earlier.
// Place the broadcast before calling the LeaveRoom API to prevent a race condition
// between Onyx report being null and Pusher's leavingStatus becoming true.
broadcastUserIsLeavingRoom(reportID);
// If a workspace member is leaving a workspace room, they don't actually lose the room from Onyx.
// Instead, their notification preference just gets set to "hidden".
const optimisticData = [
isWorkspaceMemberLeavingWorkspaceRoom
? {
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: {
notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
},
}
: {
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: {
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
statusNum: CONST.REPORT.STATUS.CLOSED,
},
},
];
const successData = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: isWorkspaceMemberLeavingWorkspaceRoom ? {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN} : _.object(reportKeys, Array(reportKeys.length).fill(null)),
},
];
API.write(
'LeaveRoom',
{
reportID,
},
{
optimisticData,
successData,
failureData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: report,
},
],
},
);
if (isWorkspaceMemberLeavingWorkspaceRoom) {
const participantAccountIDs = PersonalDetailsUtils.getAccountIDsByLogins([CONST.EMAIL.CONCIERGE]);
const chat = ReportUtils.getChatByParticipants(participantAccountIDs);
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(chat.reportID));
}
}

But it doesn't update the childReportNotificationPreference of the parent reportAction.

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

First, we should update the BE behavior on the LeaveRoom API call: it should set the parentReportAction.childReportNotificationPreference: "hidden" if the left report was a thread.

Second, he should add an optimistic Onyx merge operation to reflect this change for an appropriate offline behavior:

    if (report.parentReportID && report.parentReportActionID) {
        const parentReportAction = ReportActionsUtils.getParentReportAction(report);

        optimisticData.push({
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`,
            value: {[parentReportAction.reportActionID]: {childReportNotificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN}},
        });
        failureData.push({
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`,
            value: {[parentReportAction.reportActionID]: {childReportNotificationPreference: report.notificationPreference}},
        });
    }

We do similar on the "Unsubscribe" action here:

App/src/libs/actions/Report.js

Lines 1387 to 1398 in a59d56f

if (parentReportID && parentReportActionID) {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`,
value: {[parentReportActionID]: {childReportNotificationPreference: newValue}},
});
failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`,
value: {[parentReportActionID]: {childReportNotificationPreference: previousValue}},
});
}

What alternative solutions did you explore? (Optional)

Instead of fixing the BE, we could just call Report.updateNotificationPreference together with Report.leaveRoom, but this will result in sending 2 API calls on 1 operation, which breaks the 1:1:1 convention.

@DylanDylann
Copy link
Contributor

DylanDylann commented Oct 30, 2023

Proposal

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

Unsubscribe icon shows up after leaving your own thread

What is the root cause of that problem?

When clicking the subcribe or unsubcribe button on the ContextMenu modal. We will call toggleSubscribeToChildReport function to update Notification Preference

Report.toggleSubscribeToChildReport(lodashGet(reportAction, 'childReportID', '0'), reportAction, reportID, childReportNotificationPreference);

Report.toggleSubscribeToChildReport(lodashGet(reportAction, 'childReportID', '0'), reportAction, reportID, childReportNotificationPreference);

When leaving the thread, we don't call toggleSubscribeToChildReport to unsubscribe this thread

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

When leaving the thread, we should call toggleSubscribeToChildReport to unsubscribe this thread like we did here

onPress: (closePopover, {reportAction, reportID}) => {
let childReportNotificationPreference = lodashGet(reportAction, 'childReportNotificationPreference', '');
if (!childReportNotificationPreference) {
const isActionCreator = ReportUtils.isActionCreator(reportAction);
childReportNotificationPreference = isActionCreator ? CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS : CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN;
}
if (closePopover) {
hideContextMenu(false, () => {
ReportActionComposeFocusManager.focus();
Report.toggleSubscribeToChildReport(lodashGet(reportAction, 'childReportID', '0'), reportAction, reportID, childReportNotificationPreference);

We also consider calling toggleSubscribeToChildReport to true when the user clicks the thread again after leaving the thread

Optional: While investigating this issue I see a problem. Let's see the below image

Screenshot 2023-10-30 at 11 22 56

The unsubscribe button displayed on context menu modal even It is single message not thread (there are no child message). The RC is

const subscribed = childReportNotificationPreference !== 'hidden';

return subscribed && (isCommentAction || isReportPreviewAction || isIOUAction);

we are using this condition to display unsubcribe button

Solution: I suggest we add a condition to make sure it is a thread (Ex: childVisibleActionCount > 0). If It is true, we display unsubcribe or subcribe button

What alternative solutions did you explore? (Optional)

@melvin-bot
Copy link

melvin-bot bot commented Oct 30, 2023

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

@sakluger sakluger added the Bug Something is broken. Auto assigns a BugZero manager. label Oct 30, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 30, 2023

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

@melvin-bot melvin-bot bot removed the Overdue label Oct 30, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 30, 2023

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

@sakluger sakluger added Hourly KSv2 Overdue DeployBlockerCash This issue or pull request should block deployment labels Oct 30, 2023
@sakluger
Copy link
Contributor

I got a deploy blocker GH issue today that was a duplicate of this issue, so I've closed that one and added the relevant labels to this issue instead.

@OSBotify
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.

@melvin-bot
Copy link

melvin-bot bot commented Oct 30, 2023

Current assignee @srikarparsi is eligible for the Engineering assigner, not assigning anyone new.

@sakluger sakluger added Daily KSv2 and removed Hourly KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 30, 2023
@sakluger
Copy link
Contributor

I spoke with @MitchExpensify, neither of us think that this needs to be a deploy blocker. I'm going to leave assigned to @srikarparsi and demote back to daily, and switch the assigned BZ member from me to Mitch.

@MitchExpensify
Copy link
Contributor

MitchExpensify commented Nov 13, 2023

How is this coming along @srikarparsi ?

@melvin-bot melvin-bot bot removed the Overdue label Nov 13, 2023
@srikarparsi
Copy link
Contributor Author

Got it working! In review now :)

@srikarparsi srikarparsi added the Reviewing Has a PR in review label Nov 16, 2023
@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Nov 16, 2023
@MitchExpensify
Copy link
Contributor

Nice one!

@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels Dec 11, 2023
Copy link

melvin-bot bot commented Dec 11, 2023

This issue has not been updated in over 15 days. @ntdiary, @MitchExpensify, @srikarparsi eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@MitchExpensify
Copy link
Contributor

Good to close @srikarparsi ?

@situchan
Copy link
Contributor

PR is in review

@ntdiary ntdiary removed their assignment Jan 5, 2024
@ntdiary
Copy link
Contributor

ntdiary commented Jan 5, 2024

Hi, @MitchExpensify, can you please assign this issue to @situchan? 😄

@MitchExpensify
Copy link
Contributor

Done

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Monthly KSv2 labels Jan 10, 2024
@melvin-bot melvin-bot bot changed the title Unsubscribe icon shows up after leaving your own thread [HOLD for payment 2024-01-17] Unsubscribe icon shows up after leaving your own thread Jan 10, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jan 10, 2024
Copy link

melvin-bot bot commented Jan 10, 2024

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

Copy link

melvin-bot bot commented Jan 10, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.23-4 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-01-17. 🎊

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

  • @situchan requires payment (Needs manual offer from BZ)

Copy link

melvin-bot bot commented Jan 10, 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:

  • [@situchan] The PR that introduced the bug has been identified. Link to the PR:
  • [@situchan] 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:
  • [@situchan] 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:
  • [@situchan] Determine if we should create a regression test for this bug.
  • [@situchan] 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.
  • [@MitchExpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jan 16, 2024
Copy link

melvin-bot bot commented Jan 17, 2024

Payment Summary

Upwork Job

  • ROLE: @situchan paid $(AMOUNT) via Upwork (LINK)

BugZero Checklist (@MitchExpensify)

  • 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/1719512812572073984/hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@MitchExpensify
Copy link
Contributor

Offer here for you @situchan https://www.upwork.com/nx/wm/offer/100498634

@MitchExpensify
Copy link
Contributor

paid and contract ended! Closing

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 Engineering Internal Requires API changes or must be handled by Expensify staff
Projects
None yet
Development

No branches or pull requests

9 participants