[HOLD for payment 2021-12-06] Unread messages - Unread messages count includes deleted messages
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
- Login with 2 accounts side by side
- Tag a comment as unread and mark the count of unread comments
- Delete some comments from the sender's account
- Refresh the page
- Mark the same comment as you did in step 2. Observe the count is still the same even though the messages on screen are less
Expected Result:
If the comment was deleted it should not be included in the unread messages count.
Actual Result:
Comment that was deleted is included in the message count.
Workaround:
Not sure (🤔)
Platform:
Where is this issue occurring?
- Web
- iOS
- Android
- Desktop App
- Mobile Web
Version Number: 1.0.98-0
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
https://user-images.githubusercontent.com/44479856/133168079-a4fe5b71-5488-4dbb-92ae-d36ae02472a5.mp4
Expensify/Expensify Issue URL:
Issue reported by: @kidroca Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1631549737202800
Triggered auto assignment to @robertjchen (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.
Triggered auto assignment to @mallenexpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.
Looks like a perfect task for a contributor to tackle!
Job posted https://www.upwork.com/jobs/~01143b9e85d8cc1924
Triggered auto assignment to @puneetlath (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.
Doubled to $500
Please refer to this post for updated information on the n6 hold, we've raised the bonus to $250 for all issues where a PR is created before the N6 hold is lifted.
Proposal
- We are not filtering the deleted messages (where a deleted action is
action.html = '').
https://github.com/Expensify/App/blob/a860c59f9f7bd667f005aea269ec6fe6aa696b50/src/libs/actions/Report.js#L107
- We can get the report actions and then count the deleted messages that lie between the latest and lastReadSequenceNumber.
let deletedmessages = 0;
const handle =Onyx.connect({
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
callback: (reportActionList) => {
Onys.disconnect(handle);
_.chain(reportActions)
.sortBy('sequenceNumber')
.each((action) => {
// Empty ADDCOMMENT actions typically mean they have been deleted
const message = _.first(lodashGet(action, 'message', null));
const html = lodashGet(message, 'html', '');
if(action.sequenceNumber >= lastReadSequenceNumber && action.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && html !== ''){
deletedmessages++;
}
});
- remove the calculated count of deleted messages from the
unreadActionCountin Step 1.
@mallenexpensify Rajat's proposal sounds good to me.
@parasharrajat can apply and confirm here once you have? Thanks https://www.upwork.com/jobs/~01143b9e85d8cc1924
@mallenexpensify Done.
@parasharrajat is hired! Assigned to him
n6-hold is lifted, label removed!
PR would be up by next week.
@parasharrajat Can you provide an update on when we can expect the PR? Thanks
I have started on it. It would be ready soon. I was busy last week.
I would like to ask how the Mark as unread functionality works.
e.g. I marked the five latest messages as unread.
Now this includes messages from the Other user as well. What should be the unread message count?
@parasharrajat in the screenshot are you a different user? ie. are there 3 users in a group chat? Regardless.. I have a feeling we're going to want to raise the question in #expensify-open-source to gain consensus.
Awaiting review....
@puneetlath can you review the PR please https://github.com/Expensify/App/pull/6248