You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2023-12-29] [$500] Chat–Name of message owner disappears from DM for a second when delete first message in Offline #32101
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Version Number: v1.4.4-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: @
changed the title [-]Chat–Name of message owner disappears from DM for a second when delete first message in Offline[/-][+][$500] Chat–Name of message owner disappears from DM for a second when delete first message in Offline[/+]on Nov 28, 2023
Please re-state the problem that we are trying to solve in this issue.
When we send a message, it will show who sent it, and if we send another message within 5 minutes, it will be grouped and the 2nd (or later) message won't show who sent it anymore. If we delete the first message that has that info while offline, coming back offline makes it disappears along with the first message.
What is the root cause of that problem?
The logic to decide whether to show the user info is coming from ReportActionsUtils.isConsecutiveActionMadeByPreviousActor which will check the current and previous action sent time difference.
// Comments are only grouped if they happen within 5 minutes of each other
if (new Date(currentAction.created).getTime() - new Date(previousAction.created).getTime() > 300000) {
return false;
}
When we go online, the first message that we optimistically delete disappears thanks to OfflineWithFeedback, but the first message report action object actually still exists (assuming the delete action API isn't complete yet) in the Onyx.
So, when we compare the 2nd message with the 1st message sent time, it's obvious that the user info won't show. After the API completes, the 1st message is deleted from the Onyx and the 2nd message is now the 1st message and because the previous action is CREATED action, the user info is shown.
But this is not the real root cause. If we see the logic on how we retrieve the previous action, we already skip any action that has a pending delete while ONLINE.
function findPreviousAction(reportActions: ReportAction[] | null, actionIndex: number): OnyxEntry<ReportAction> {
if (!reportActions) {
return null;
}
for (let i = actionIndex + 1; i < reportActions.length; i++) {
// Find the next non-pending deletion report action, as the pending delete action means that it is not displayed in the UI, but still is in the report actions list.
// If we are offline, all actions are pending but shown in the UI, so we take the previous action, even if it is a delete.
if (isNetworkOffline || reportActions[i].pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) {
return reportActions[i];
}
}
The problem is, that we memorized ReportActionsListItemRenderer
so even when the network status changes, the component won't rerender.
What changes do you think we should make in order to solve the problem?
Subscribe the network status in ReportActionsListItemRenderer and pass it to ReportActionsUtils.isConsecutiveActionMadeByPreviousActor > ReportActionsUtils.findPreviousAction.
if (isNetworkOffline || reportActions[i].pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) {
we already have the logic to check isNetworkOffline, but isConsecutiveActionMadeByPreviousActor function is not called when the users go online because in ReportActionsListItemRenderer we did not listen for network change
-> displayAsGroup is not updated immediately. When API DeleteComment calls successfully that makes sortedReportActions get changed -> ReportActionsListItemRenderer is re-rendered -> displayAsGroup is updated
What changes do you think we should make in order to solve the problem?
We don't need to pass whole sortedReportActions to ReportActionsListItemRenderer because this component is used to render only 1 item and we just need it to get displayAsGroup -> it can cause this component re-renders unexpectedly.
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:
[@shubham1206agra] The PR that introduced the bug has been identified. Link to the PR:
[@shubham1206agra] 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:
[@shubham1206agra] 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:
[@shubham1206agra] Determine if we should create a regression test for this bug.
[@shubham1206agra] 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.
[@kevinksullivan] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
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:
[@shubham1206agra] 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: No need as they are optimizing performance and forgot to add offline tests.
[@shubham1206agra] Determine if we should create a regression test for this bug. Yes
[@shubham1206agra] 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.
Go to App
Send someone messages back-to-back.
Disable the internet connection.
Choose the first of several messages you already sent back-to-back
Verify the chat header with your name appears only on your first message
Hover over that first message to view the action menu
Click/Tap on the Trash icon to delete the message
Go Online
[@kevinksullivan] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Activity
[-]Chat–Name of message owner disappears from DM for a second when delete first message in Offline[/-][+][$500] Chat–Name of message owner disappears from DM for a second when delete first message in Offline[/+]melvin-bot commentedon Nov 28, 2023
Job added to Upwork: https://www.upwork.com/jobs/~012bb87b742d38cd4b
melvin-bot commentedon Nov 28, 2023
Triggered auto assignment to @kevinksullivan (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Nov 28, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)melvin-bot commentedon Nov 28, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Santhosh-Sellavel (
External)AmjedNazzal commentedon Nov 28, 2023
@izarutskaya Can you please check the screenshots/videos section, it seemed to have not uploaded correctly.
bernhardoj commentedon Nov 28, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
When we send a message, it will show who sent it, and if we send another message within 5 minutes, it will be grouped and the 2nd (or later) message won't show who sent it anymore. If we delete the first message that has that info while offline, coming back offline makes it disappears along with the first message.
What is the root cause of that problem?
The logic to decide whether to show the user info is coming from
ReportActionsUtils.isConsecutiveActionMadeByPreviousActorwhich will check the current and previous action sent time difference.App/src/pages/home/report/ReportActionsListItemRenderer.js
Line 76 in 48e0c1e
App/src/libs/ReportActionsUtils.ts
Lines 258 to 261 in 48e0c1e
When we go online, the first message that we optimistically delete disappears thanks to
OfflineWithFeedback, but the first message report action object actually still exists (assuming the delete action API isn't complete yet) in the Onyx.So, when we compare the 2nd message with the 1st message sent time, it's obvious that the user info won't show. After the API completes, the 1st message is deleted from the Onyx and the 2nd message is now the 1st message and because the previous action is CREATED action, the user info is shown.
But this is not the real root cause. If we see the logic on how we retrieve the previous action, we already skip any action that has a pending delete while ONLINE.
App/src/libs/ReportActionsUtils.ts
Lines 226 to 237 in 48e0c1e
The problem is, that we memorized
ReportActionsListItemRendererApp/src/pages/home/report/ReportActionsListItemRenderer.js
Line 93 in 48e0c1e
which only rerenders when the props change, but the network status (
isNetworkOffline) is coming from the util file itself,App/src/libs/ReportActionsUtils.ts
Lines 49 to 53 in 48e0c1e
so even when the network status changes, the component won't rerender.
What changes do you think we should make in order to solve the problem?
Subscribe the network status in
ReportActionsListItemRendererand pass it toReportActionsUtils.isConsecutiveActionMadeByPreviousActor>ReportActionsUtils.findPreviousAction.tienifr commentedon Nov 28, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
Chat–Name of message owner disappears from DM for a second when delete first message in Offline
What is the root cause of that problem?
we decide to display the chat-name based on
displayAsGrouphereApp/src/pages/home/report/ReportActionsListItemRenderer.js
Line 76 in 9b1f465
in
App/src/libs/ReportActionsUtils.ts
Line 234 in 48e0c1e
we already have the logic to check
isNetworkOffline, but isConsecutiveActionMadeByPreviousActor function is not called when the users go online because inReportActionsListItemRendererwe did not listen for network change-> displayAsGroup is not updated immediately. When API
DeleteCommentcalls successfully that makessortedReportActionsget changed -> ReportActionsListItemRenderer is re-rendered -> displayAsGroup is updatedWhat changes do you think we should make in order to solve the problem?
We don't need to pass whole
sortedReportActionstoReportActionsListItemRendererbecause this component is used to render only 1 item and we just need it to get displayAsGroup -> it can cause this component re-renders unexpectedly.Instead of that we should pass
in
App/src/pages/home/report/ReportActionsList.js
Line 378 in 0c78c5b
and remove this line
App/src/pages/home/report/ReportActionsList.js
Line 384 in 0c78c5b
then use
displayAsGroupin hereFor now, we can make sure displayAsGroup will be updated after uses go online because we already listen for network change in
ReportActionsListResult
Screen.Recording.2023-11-28.at.23.39.15.mov
Santhosh-Sellavel commentedon Nov 29, 2023
@tienifr's proposal LGTM!
C+ Reviewed
🎀 👀 🎀
54 remaining items
melvin-bot commentedon Dec 22, 2023
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:
melvin-bot commentedon Jan 2, 2024
@Julesssss, @kevinksullivan, @shubham1206agra, @tienifr Huh... This is 4 days overdue. Who can take care of this?
shubham1206agra commentedon Jan 3, 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:
melvin-bot commentedon Jan 4, 2024
@Julesssss, @kevinksullivan, @shubham1206agra, @tienifr Still overdue 6 days?! Let's take care of this!
shubham1206agra commentedon Jan 8, 2024
@kevinksullivan Bump for the payment here
melvin-bot commentedon Jan 8, 2024
@Julesssss, @kevinksullivan, @shubham1206agra, @tienifr 10 days overdue. Is anyone even seeing these? Hello?
Julesssss commentedon Jan 8, 2024
Not overdue, just awaiting payment
melvin-bot commentedon Jan 10, 2024
@Julesssss, @kevinksullivan, @shubham1206agra, @tienifr 12 days overdue. Walking. Toward. The. Light...
Julesssss commentedon Jan 12, 2024
Waiting for payment
kevinksullivan commentedon Jan 12, 2024
Thanks for your patience, everyone! Paid out.