Fix report action draft still present after deleting the workspace#30049
Fix report action draft still present after deleting the workspace#30049cead22 merged 8 commits intoExpensify:mainfrom
Conversation
|
@aimane-chnaif Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
Additional video showing the draft is deleted when the workspace is deleted from another client/device Screen.Recording.2023-10-20.at.11.35.22.mov |
| if (!_.isString(reportActionDraft)) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
NAB: Is there any non-string case?
There was a problem hiding this comment.
One case is when the action draft is already migrated to an object, so we skip it.
I don't know if it is possible that a user have both old and new structure of action draft, but just to be safe.
Reviewer Checklist
Screenshots/VideosWebweb-ios.movMigration testBefore: before.migration.movAfter: after.migration.movMobile Web - Chromedesktop-mchrome.movMobile Web - Safariandroid-msafari.movDesktopdesktop-mchrome.moviOSweb-ios.movAndroidandroid-msafari.mov |
| const reportActionID = onyxKey.split('_').pop(); | ||
| const newOnyxKey = onyxKey.replace(`_${reportActionID}`, ''); | ||
| newReportActionsDrafts[newOnyxKey] = { | ||
| ...(newReportActionsDrafts[newOnyxKey] || allReportActionsDrafts[newOnyxKey]), |
There was a problem hiding this comment.
What does || allReportActionsDrafts[newOnyxKey] do in here? do we ever set allReportActionsDrafts[newOnyxKey]?
There was a problem hiding this comment.
It's to cover a case where there is already an existing migrated draft of newOnyxKey.
the example is on the 2nd unit test
There was a problem hiding this comment.
Can you add a comment to make that obvious please? I see the test, and with one of the values for reportID 2 set to {} and one to null, but is that something that can happen, like having a migration run half-way?
There was a problem hiding this comment.
Added the comment.
but is that something that can happen, like having a migration run half-way?
I'm not sure actually, but I see the other existing tests and they include that kind of case.
| newReportActionsDrafts[newOnyxKey] = { | ||
| ...(newReportActionsDrafts[newOnyxKey] || | ||
| // Includes the existing migrated draft | ||
| allReportActionsDrafts[newOnyxKey]), | ||
| [reportActionID]: reportActionDraft, | ||
| }; |
There was a problem hiding this comment.
This is now very hard to read, can we make it less fancy and more readable, maybe like this?
| newReportActionsDrafts[newOnyxKey] = { | |
| ...(newReportActionsDrafts[newOnyxKey] || | |
| // Includes the existing migrated draft | |
| allReportActionsDrafts[newOnyxKey]), | |
| [reportActionID]: reportActionDraft, | |
| }; | |
| // If newReportActionsDrafts[newOnyxKey] isn't set, fall back on the migrated draft if there is one | |
| const currentActionDrafts = newReportActionsDrafts[newOnyxKey] || allReportActionsDrafts[newOnyxKey]; | |
| newReportActionsDrafts[newOnyxKey] = { | |
| ...currentActionDrafts, | |
| [reportActionID]: reportActionDraft, | |
| }; |
There was a problem hiding this comment.
Thanks for the suggestion! I have updated the code.
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/cead22 in version: 1.3.91-1 🚀
|
|
🚀 Deployed to production by https://github.com/marcaaron in version: 1.3.91-8 🚀
|
|
🚀 Deployed to staging by https://github.com/cead22 in version: 1.3.93-0 🚀
|
|
🚀 Deployed to production by https://github.com/Beamanator in version: 1.3.93-1 🚀
|
Details
When we delete a workspace, all workspace-related chat is archived, and not allowed to edit any message, but every message on edit is still present allowing to user to edit it but eventually, an error is thrown from the BE.
Fixed Issues
$ #26887
PROPOSAL: #26887 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
Prerequisites: have a workspace
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Screen.Recording.2023-10-20.at.11.49.04.mov
Android: mWeb Chrome
Screen.Recording.2023-10-20.at.11.27.12.mov
iOS: Native
Screen.Recording.2023-10-20.at.11.33.22.mov
iOS: mWeb Safari
Screen.Recording.2023-10-20.at.11.28.20.mov
MacOS: Chrome / Safari
Screen.Recording.2023-10-20.at.11.10.25.mov
MacOS: Desktop
Screen.Recording.2023-10-20.at.11.13.00.mov