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 2024-01-17] [$500] Workspace-Edited&deleted message remains in # when back online when other login delete workspace #32529
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: 1.4.8-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: @
Action Performed:
Navigate to staging.new.expensify..com
Create workspace
Go to #announce room
Switch to offline mode
Send 3 messages to the room
Delete the first message and edit the second message
From other device delete the workspace
Come back online
Expected Result:
Messages added in offline mode should disappear when other user delete the workspace
Actual Result:
Only edited and deleted message appears in Announce when user come back online, after second login delete the workspace
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
changed the title [-]Workspace-Edited&deleted message remains in # when back online when other login delete workspace[/-][+][$500] Workspace-Edited&deleted message remains in # when back online when other login delete workspace[/+]on Dec 5, 2023
Please re-state the problem that we are trying to solve in this issue.
Adding a message in a workspace chat while offline and then deleting the workspace from another device then coming back online will show an error message for each message we added. Pressing the close button of the error message will delete the message, but this doesn't work if we edit/delete the message while offline.
What is the root cause of that problem?
It's expected that adding/deleting/editing a message while offline but the chat is archived will throw an error. When we press the close error button, it will delete the message if the pending action is ADD.
We want to delete it because it is never added to the server because the chat is already archived. The problem is if we delete/edit the message, the pending action of ADD will be overwritten by UPDATE or DELETE.
This is the limitation of having a single pending action.
What changes do you think we should make in order to solve the problem?
I think we can start introducing a pending action collection. To minimize changes, we can introduce a new property called pendingActions (with s). pendingActions will contain a list of pending actions (in a form of object) that the user made.
To achieve that, let's add the pendingActions when adding, editing, and deleting the message/action optimistically.
We also need to clear it when the request fails/success (for add message, we only clear it on success)
pendingActions: {
[currentTime]: null,
},
(add the above code in addActions, editReportComment, and deleteReportComment)
We get the currentTime from DateUtils.getDBTime(). The reason I use currentTime is so that the pending action is sorted like a stack. I don't use array because merging an array will replace the previous array.
After we have the new pendingActions, we can now check if the report action pendingActions contains an ADD action. If true, then we delete the optimistic report action.
So, if we add, edit, and then delete a single message (pendingActions = ADD, UPDATE, DELETE) and all of them fails (pendingActions = ADD), we still have the pendingAction of ADD which will reduce the opacity of the message which currently doesn't happen on main.
What alternative solutions did you explore? (Optional)
Instead of having a pendingActions, we can introduce a new property called isOptimisticAction. We will set it to true optimistically when adding a new comment and clear it when it is successful.
The PR that introduced the bug has been identified. Link to the PR: there isn't a specific PR that caused this, this is a limitation of the original implementation we've had
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: N/A
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: don't think an additional discussion is needed here, this is an edge case
Determine if we should create a regression test for this bug.
Is it easy to test for this bug? Yes
Is the bug related to an important user flow? Yes
Is it an impactful bug? No
This is an edge case and the bug isn't impactful (users can continue using the app), but it's easy to test and, most importantly, messaging is integral part of the app, so I think we need to add a regression test for this
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
melvin-bot commentedon Dec 5, 2023
Triggered auto assignment to @muttmuure (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.[-]Workspace-Edited&deleted message remains in # when back online when other login delete workspace[/-][+][$500] Workspace-Edited&deleted message remains in # when back online when other login delete workspace[/+]melvin-bot commentedon Dec 5, 2023
Job added to Upwork: https://www.upwork.com/jobs/~0122148165eaf3972f
melvin-bot commentedon Dec 5, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)melvin-bot commentedon Dec 5, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @eVoloshchak (
External)bernhardoj commentedon Dec 6, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
Adding a message in a workspace chat while offline and then deleting the workspace from another device then coming back online will show an error message for each message we added. Pressing the close button of the error message will delete the message, but this doesn't work if we edit/delete the message while offline.
What is the root cause of that problem?
It's expected that adding/deleting/editing a message while offline but the chat is archived will throw an error. When we press the close error button, it will delete the message if the pending action is ADD.
App/src/libs/actions/ReportActions.ts
Lines 16 to 34 in 5a0b7fd
We want to delete it because it is never added to the server because the chat is already archived. The problem is if we delete/edit the message, the pending action of ADD will be overwritten by UPDATE or DELETE.
App/src/libs/actions/Report.js
Lines 1276 to 1277 in 5a0b7fd
App/src/libs/actions/Report.js
Line 1090 in 5a0b7fd
And if one of them fails, we clear the pending action.
App/src/libs/actions/Report.js
Lines 1311 to 1318 in 5a0b7fd
This is the limitation of having a single pending action.
What changes do you think we should make in order to solve the problem?
I think we can start introducing a pending action collection. To minimize changes, we can introduce a new property called
pendingActions(withs).pendingActionswill contain a list of pending actions (in a form of object) that the user made.To achieve that, let's add the
pendingActionswhen adding, editing, and deleting the message/action optimistically.We also need to clear it when the request fails/success (for add message, we only clear it on success)
(add the above code in
addActions,editReportComment, anddeleteReportComment)We get the
currentTimefromDateUtils.getDBTime(). The reason I usecurrentTimeis so that the pending action is sorted like a stack. I don't use array because merging an array will replace the previous array.After we have the new
pendingActions, we can now check if the report actionpendingActionscontains an ADD action. If true, then we delete the optimistic report action.App/src/libs/actions/ReportActions.ts
Line 16 in 5a0b7fd
Last, to show the correct offline feedback, we should get the last pending action and pass it to
OfflineWithFeedback.App/src/pages/home/report/ReportActionItem.js
Line 699 in 5a0b7fd
So, if we add, edit, and then delete a single message (pendingActions = ADD, UPDATE, DELETE) and all of them fails (pendingActions = ADD), we still have the
pendingActionof ADD which will reduce the opacity of the message which currently doesn't happen onmain.What alternative solutions did you explore? (Optional)
Instead of having a
pendingActions, we can introduce a new property calledisOptimisticAction. We will set it to true optimistically when adding a new comment and clear it when it is successful.muttmuure commentedon Dec 8, 2023
Still being discussed
32 remaining items
muttmuure commentedon Jan 22, 2024
C+ - @eVoloshchak $500
muttmuure commentedon Jan 22, 2024
@bernhardoj paid on Upwork
muttmuure commentedon Jan 22, 2024
Let us know if we should add a regression test
eVoloshchak commentedon Jan 23, 2024
Is it easy to test for this bug? Yes
Is the bug related to an important user flow? Yes
Is it an impactful bug? No
This is an edge case and the bug isn't impactful (users can continue using the app), but it's easy to test and, most importantly, messaging is integral part of the app, so I think we need to add a regression test for this
eVoloshchak commentedon Jan 23, 2024
Regression Test Proposal
Do we agree 👍 or 👎
JmillsExpensify commentedon Jan 25, 2024
$500 approved for @eVoloshchak based on this comment.
muttmuure commentedon Jan 29, 2024
I'll ask Applause for feedback on this: #32529 (comment)
melvin-bot commentedon Feb 1, 2024
@eVoloshchak, @marcaaron, @muttmuure, @bernhardoj Whoops! This issue is 2 days overdue. Let's get this updated quick!
melvin-bot commentedon Mar 23, 2024
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.