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-01] MEDIUM: Notification counter has phantom unreads #33506

Closed
1 of 6 tasks
m-natarajan opened this issue Dec 22, 2023 · 30 comments
Closed
1 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

@m-natarajan
Copy link

m-natarajan commented Dec 22, 2023

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.16-3
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: @shawnborton
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1703179378879089

Action Performed:

  1. View the thread of a public room created on a private workspace

Expected Result:

Just looking at a thread shouldn't join it (you need to explicitly join a thread and subscribe to it), and thus shouldn't generate notifications.

Actual Result:

I think the actions here are that I viewed a thread, but didn't participate in it. As such, whenever that thread got a new message, my notification count went up but I had no unread messages in my LHN.

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

Recording.348.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0197ab62db4a5e9ffd
  • Upwork Job ID: 1738248320594354176
  • Last Price Increase: 2023-12-29
  • Automatic offers:
    • cubuspl42 | Contributor | 28080118
@m-natarajan m-natarajan 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 Dec 22, 2023
@melvin-bot melvin-bot bot changed the title Notification counter has phantom unreads [$500] Notification counter has phantom unreads Dec 22, 2023
Copy link

melvin-bot bot commented Dec 22, 2023

Job added to Upwork: https://www.upwork.com/jobs/~0197ab62db4a5e9ffd

Copy link

melvin-bot bot commented Dec 22, 2023

Triggered auto assignment to @CortneyOfstad (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 Dec 22, 2023
Copy link

melvin-bot bot commented Dec 22, 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

Copy link

melvin-bot bot commented Dec 22, 2023

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

@gijoe0295
Copy link
Contributor

gijoe0295 commented Dec 22, 2023

Proposal

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

Unread counter includes reports with hidden notification preference.

What is the root cause of that problem?

Although notification preference was hidden, the Pusher still notified user about this report.

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

Unread counter includes reports with hidden notification preference. We should add a condition to exclude them here:

const unreadReports = Object.values(allReports ?? {}).filter(
(report) => ReportUtils.isUnread(report) && ReportUtils.shouldReportBeInOptionList(report, currentReportID ?? '', false, [], {}),
);

This is the easiest fix.

What alternative solutions did you explore? (Optional)

Fix the BE not to notify hidden notification reports.

@bernhardoj
Copy link
Contributor

bernhardoj commented Dec 23, 2023

Proposal

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

The notification counter goes up when a new message arrives on a report with a HIDDEN notification preference.

What is the root cause of that problem?

When we have a report with notification preference set to HIDDEN, the report won't be shown on the LHN.

Currently, we already exclude any report that doesn't show on LHN from the unread count.

// We want to keep notification count consistent with what can be accessed from the LHN list
const unreadReports = Object.values(allReports ?? {}).filter(
(report) => ReportUtils.isUnread(report) && ReportUtils.shouldReportBeInOptionList(report, currentReportID ?? '', false, [], {}),
);

However, the logic to hide a report with a notification preference of HIDDEN is not included in shouldReportBeInOptionList. The way we hide it is by returning null for OptionRowLHN.

const isHidden = optionItem.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN;
if (isHidden && !props.isFocused && !optionItem.isPinned) {
return null;
}

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

We should move the logic to hide a report with notification preference of HIDDEN to shouldReportBeInOptionList.

if (report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN) {
    return false;
}

But the notificationPreference property isn't available because we use a selector here, so we need to include notificationPreference too.

const chatReportSelector = (report) =>
report && {
reportID: report.reportID,
participantAccountIDs: report.participantAccountIDs,
hasDraft: report.hasDraft,
isPinned: report.isPinned,
isHidden: report.isHidden,
errorFields: {
addWorkspaceRoom: report.errorFields && report.errorFields.addWorkspaceRoom,
},
lastMessageText: report.lastMessageText,
lastVisibleActionCreated: report.lastVisibleActionCreated,
iouReportID: report.iouReportID,
total: report.total,
nonReimbursableTotal: report.nonReimbursableTotal,
hasOutstandingChildRequest: report.hasOutstandingChildRequest,
isWaitingOnBankAccount: report.isWaitingOnBankAccount,
statusNum: report.statusNum,
stateNum: report.stateNum,
chatType: report.chatType,
type: report.type,
policyID: report.policyID,
visibility: report.visibility,
lastReadTime: report.lastReadTime,
// Needed for name sorting:
reportName: report.reportName,
policyName: report.policyName,
oldPolicyName: report.oldPolicyName,
// Other less obvious properites considered for sorting:
ownerAccountID: report.ownerAccountID,
currency: report.currency,
managerID: report.managerID,
// Other important less obivous properties for filtering:
parentReportActionID: report.parentReportActionID,
parentReportID: report.parentReportID,
};

This way, we have a "single source of truth".

Copy link

melvin-bot bot commented Dec 26, 2023

@CortneyOfstad, @0xmiroslav Whoops! This issue is 2 days overdue. Let's get this updated quick!

Copy link

melvin-bot bot commented Dec 28, 2023

@CortneyOfstad, @0xmiroslav Eep! 4 days overdue now. Issues have feelings too...

Copy link

melvin-bot bot commented Dec 29, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

Copy link

melvin-bot bot commented Jan 1, 2024

@CortneyOfstad, @0xmiroslav Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!

Copy link

melvin-bot bot commented Jan 2, 2024

@CortneyOfstad, @0xmiroslav 10 days overdue. I'm getting more depressed than Marvin.

@CortneyOfstad
Copy link
Contributor

Was OoO for the holidays — sorry for the delay here!

@0xmiroslav any thoughts on the proposals above? Thanks!

@melvin-bot melvin-bot bot removed the Overdue label Jan 2, 2024
@marcaaron marcaaron changed the title [$500] Notification counter has phantom unreads Notification counter has phantom unreads Jan 4, 2024
@marcaaron marcaaron assigned cubuspl42 and unassigned 0xmiros Jan 4, 2024
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 4, 2024
Copy link

melvin-bot bot commented Jan 4, 2024

📣 @cubuspl42 🎉 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 Weekly KSv2 and removed Daily KSv2 labels Jan 5, 2024
@allroundexperts
Copy link
Contributor

PR created #34025

@puneetlath
Copy link
Contributor

Once that PR is done, I'd love to hear what ideas there are to make sure this regression doesn't happen again. I feel like this issue keeps cropping up over and over. At the minimum, let's make sure we have some good manual regression tests in place. But maybe we could add some automated tests or something too?

@marcaaron
Copy link
Contributor

marcaaron commented Jan 8, 2024

Agree. If we go the automated route... we should be able to do something like this:

diff --git a/src/libs/UnreadIndicatorUpdater/index.ts b/src/libs/UnreadIndicatorUpdater/index.ts
index 4126f2af4e..9c7fffd52a 100644
--- a/src/libs/UnreadIndicatorUpdater/index.ts
+++ b/src/libs/UnreadIndicatorUpdater/index.ts
@@ -8,13 +8,17 @@ import updateUnread from './updateUnread';

 let allReports: OnyxCollection<Report> = {};

+function getUnreadReportsForUnreadIndicator(currentReportID) {
+    return Object.values(allReports ?? {}).filter(
+        (report) => ReportUtils.isUnread(report) && ReportUtils.shouldReportBeInOptionList(report, currentReportID ?? '', false, [], {}),
+    )
+}
+
 const triggerUnreadUpdate = () => {
     const currentReportID = navigationRef.isReady() ? Navigation.getTopmostReportId() : '';

     // We want to keep notification count consistent with what can be accessed from the LHN list
-    const unreadReports = Object.values(allReports ?? {}).filter(
-        (report) => ReportUtils.isUnread(report) && ReportUtils.shouldReportBeInOptionList(report, currentReportID ?? '', false, [], {}),
-    );
+    const unreadReports = getUnreadReportsForUnreadIndicator(currentReportID);
     updateUnread(unreadReports.length);
 };

(obviously do not use the broken logic that is there 😄)

But we can export the getUnreadReportsForUnreadIndicator() and then add a unit test for the various cases.

@puneetlath
Copy link
Contributor

I love that. @cubuspl42 @allroundexperts what do you think? Shall we include it in the PR? Or perhaps do it as a follow-up?

@cubuspl42
Copy link
Contributor

If we're gonna add this, maybe it's easier to include this in the already open PR.

What could also help would be adding some comment here, as this is quite a special value with special meaning (unlike the other options which directly corresponds to actual user-picked preference).

@quinthar
Copy link
Contributor

Hi! What's the status of this? What's the next step, who is doing it, and when will it happen?

@quinthar quinthar changed the title Notification counter has phantom unreads MEDIUM: Notification counter has phantom unreads Jan 22, 2024
@cubuspl42
Copy link
Contributor

This time it's on me! The latest comments were resolved before the weekend. I'll do the final testing, and very likely, this will be mergeable today.

@CortneyOfstad
Copy link
Contributor

Thanks @cubuspl42!

@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 25, 2024
@melvin-bot melvin-bot bot changed the title MEDIUM: Notification counter has phantom unreads [HOLD for payment 2024-02-01] MEDIUM: Notification counter has phantom unreads Jan 25, 2024
Copy link

melvin-bot bot commented Jan 25, 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 25, 2024
Copy link

melvin-bot bot commented Jan 25, 2024

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

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

Copy link

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

  • [@cubuspl42 / @allroundexperts] The PR that introduced the bug has been identified. Link to the PR:
  • [@cubuspl42 / @allroundexperts] 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:
  • [@cubuspl42 / @allroundexperts] 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:
  • [@cubuspl42 / @allroundexperts] Determine if we should create a regression test for this bug.
  • [@cubuspl42 / @allroundexperts] 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.
  • [@CortneyOfstad] 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 Overdue and removed Weekly KSv2 labels Jan 31, 2024
@CortneyOfstad
Copy link
Contributor

Payment is not due until tomorrow 👍

@melvin-bot melvin-bot bot removed the Overdue label Jan 31, 2024
@situchan
Copy link
Contributor

I think this can be closed based on #33506 (comment)

@CortneyOfstad
Copy link
Contributor

@Gonals does that sound good ^^^?

@Gonals
Copy link
Contributor

Gonals commented Feb 1, 2024

Yep!

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
No open projects
Status: CRITICAL
Development

No branches or pull requests