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

[$1000] Chat - 'New message' pill appears after deleting unread message #22174

Closed
1 of 6 tasks
lanitochka17 opened this issue Jul 4, 2023 · 74 comments
Closed
1 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Jul 4, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Issue found when executing PR #21557

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to any chat
  3. Send a message
  4. Mark the message unread
  5. Scroll up and click on the 'new message' pill
  6. Delete the unread message
  7. Scroll up

Expected Result:

'New message' pill will not appear as the unread message is deleted

Actual Result:

'New message' pill still appears although the unread message is deleted
If the 'new message' pill is not clicked, this issue will not occur.

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.36.2

Reproducible in staging?: Yes

Reproducible in production?: Yes

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

Notes/Photos/Videos: Any additional supporting documentation

Bug6115722_bandicam_2023-07-04_17-01-06-305

Bug6115722_bandicam_2023-07-04_17-00-30-382.mp4

Expensify/Expensify Issue URL:

Issue reported by: Applause - Internal Team

Slack conversation:

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01c35abc455d11baf9
  • Upwork Job ID: 1678381225562419200
  • Last Price Increase: 2023-07-31
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 4, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 4, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jul 4, 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

@samh-nl
Copy link
Contributor

samh-nl commented Jul 4, 2023

Proposal

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

The 'New message' pill remains despite an unread message being deleted.

What is the root cause of that problem?

When deleting a message, pendingAction is set to 'delete'. This is meant to be detected by this useEffect and should lead to the marker being refreshed if it has changed.

useEffect(() => {
// If the last unread message was deleted, remove the *New* green marker and the *New Messages* notification at scroll just as the deletion starts.
if (
!(
ReportUtils.isUnread(props.report) &&
props.reportActions.length > 0 &&
props.reportActions[0].pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE &&
!props.network.isOffline
)
) {
return;
}
const reportActionsWithoutPendingOne = lodashCloneDeep(props.reportActions);
reportActionsWithoutPendingOne.shift();
if (newMarkerReportActionID !== ReportUtils.getNewMarkerReportActionID(props.report, reportActionsWithoutPendingOne)) {
setNewMarkerReportActionID(ReportUtils.getNewMarkerReportActionID(props.report, reportActionsWithoutPendingOne));
}
}, [props.report, props.reportActions, props.network, newMarkerReportActionID]);

However, when clicking the 'New messages' pill, the report is marked as read, causing the useEffect to not process this change due to ReportUtils.isUnread(props.report) &&.

const scrollToBottomAndMarkReportAsRead = () => {
reportScrollManager.scrollToBottom();
Report.readNewestAction(props.report.reportID);
};

As the deletion comes after clicking the pill, the if-statement in the useEffect will evaluate to true and it will therefore return; early, preventing the marker from being refreshed/removed.

The result is that the 'New messages' pill persists, which is the problem we are observing.

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

In the useEffect, we must replaceReportUtils.isUnread(props.report) && with !_.isEmpty(newMarkerReportActionID) &&.

ReportUtils.isUnread(props.report) &&

What alternative solutions did you explore? (Optional)

Alternatively, we can add setNewMarkerReportActionID(''); in the scrollToBottomAndMarkReportAsRead function.
This function is called when clicking the 'New messages' pill and marks the report as read. However, performing this change will remove the marker immediately upon clicking the pill, which may not be desired as it leaves the user with no information about what messages were newly added, which seems like the best UX and therefore the intended behavior.

<FloatingMessageCounter
isActive={isFloatingMessageCounterVisible && !_.isEmpty(newMarkerReportActionID)}
onClick={scrollToBottomAndMarkReportAsRead}
/>

const scrollToBottomAndMarkReportAsRead = () => {
reportScrollManager.scrollToBottom();
Report.readNewestAction(props.report.reportID);
};

A second alternative is to detect a discrepancy between ReportUtils.isUnread(props.report) and newMarkerReportActionID using a useEffect hook and remove the marker if the report is read. However, this suffers from the same drawback as mentioned above. It will immediately reset the marker.

Edit: Updated proposal based on refactored component

@DanutGavrus
Copy link
Contributor

This reported issue has the same root cause as this which was found while testing this PR. We were thinking and decided that the issue is out of scope of that PR.

Here are my findings:

  1. This reported bug happens if we remove all the changes introduced by the PR;
  2. This reported bug does not happen if we introduce the changes proposed here.

Right now, New Markers Issues are on hold as I've found out from this comment. Lately I've seen quite some issues arising from the same root cause, which is that the New Markers do not get removed when report becomes read. Maybe we want to make an exception to fix them all with 1 Proposal, or we'll keep them all on hold until the refactor is done.

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jul 6, 2023
@anmurali
Copy link

Reproduced on Chrome/ Mac

@melvin-bot melvin-bot bot removed the Overdue label Jul 10, 2023
@anmurali anmurali added the External Added to denote the issue can be worked on by a contributor label Jul 10, 2023
@melvin-bot melvin-bot bot changed the title Chat - 'New message' pill appears after deleting unread message [$1000] Chat - 'New message' pill appears after deleting unread message Jul 10, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 10, 2023

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 10, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 10, 2023

Current assignee @anmurali is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Jul 10, 2023

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

@DanutGavrus
Copy link
Contributor

Based on this I think we'll have to put this on hold for #15212

@melvin-bot melvin-bot bot added the Overdue label Jul 12, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 13, 2023

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

@anmurali
Copy link

@0xmiroslav - do you agree with @DanutGavrus? If yes, I will add the held to the title and degrade this to a weekly while we wait.

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jul 14, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 17, 2023

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

@anmurali
Copy link

@0xmiroslav bump

@melvin-bot melvin-bot bot removed the Overdue label Jul 17, 2023
@0xmiros
Copy link
Contributor

0xmiros commented Jul 18, 2023

@samh-nl @DanutGavrus ReportActionsView is now refactored to function component. Please update your proposals accordingly.

@DanutGavrus
Copy link
Contributor

@0xmiroslav

ReportActionsView is now refactored to function component. Please update your proposals accordingly.

Proposal

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

Chat - 'New message' pill appears after deleting unread message.

What is the root cause of that problem?

  1. Clicking on the New Messages pill automatically sets the report as read;
  2. But, in ReportActionsView.js we do not check if the report automatically became read in order to clear newMarkerReportActionID's value.

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

We should add this logic:

useEffect(() => {
    // If the report automatically became read, remove the *New* green marker and the *New Messages* notification at scroll.
    if (!ReportUtils.isUnread(props.report) && newMarkerReportActionID != '') {
        setNewMarkerReportActionID('');
    }
}, [props.report, newMarkerReportActionID]);

@amyevans
Copy link
Contributor

To be honest I'm not sure which is the expected behavior. @MonilBhavsar I know you've spent much more time than me diving into the logic and expectations of the unread marker, can you weigh in on the expected behavior question here please: #22174 (comment)

@MonilBhavsar
Copy link
Contributor

MonilBhavsar commented Oct 11, 2023

Option 1 is correct based on the design doc 👍
Just to note, there's an ongoing PR to update the unread functionality. May be if we want to put this issue on HOLD for that, so we don't update code in parallel #25935 cc @gedu

@amyevans
Copy link
Contributor

Okay thanks so much @MonilBhavsar!

@amyevans amyevans changed the title [$1000] Chat - 'New message' pill appears after deleting unread message [HOLD 25935][$1000] Chat - 'New message' pill appears after deleting unread message Oct 11, 2023
@amyevans amyevans added Weekly KSv2 External Added to denote the issue can be worked on by a contributor Daily KSv2 and removed Daily KSv2 Weekly KSv2 Internal Requires API changes or must be handled by Expensify staff labels Oct 11, 2023
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 11, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 11, 2023

Current assignee @situchan is eligible for the External assigner, not assigning anyone new.

@amyevans amyevans added Weekly KSv2 and removed Daily KSv2 labels Oct 11, 2023
@melvin-bot melvin-bot bot added the Overdue label Oct 20, 2023
@amyevans
Copy link
Contributor

Still on hold

@melvin-bot melvin-bot bot removed the Overdue label Oct 23, 2023
@melvin-bot melvin-bot bot added the Overdue label Nov 1, 2023
@situchan
Copy link
Contributor

situchan commented Nov 2, 2023

Same

@amyevans
Copy link
Contributor

Still holding

@melvin-bot melvin-bot bot removed the Overdue label Nov 14, 2023
@MonilBhavsar
Copy link
Contributor

This issue should be fixed! We can retest and most probably close this

@melvin-bot melvin-bot bot added the Overdue label Nov 23, 2023
@amyevans
Copy link
Contributor

Thanks Monil! Retested and confirmed it's fixed:

retest-22174.mov

@melvin-bot melvin-bot bot removed the Overdue label Nov 27, 2023
@amyevans amyevans changed the title [HOLD 25935][$1000] Chat - 'New message' pill appears after deleting unread message [$1000] Chat - 'New message' pill appears after deleting unread message Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Weekly KSv2
Projects
None yet
Development

No branches or pull requests