Fix: Two reports are opened when two users first open the report simultaneously#24295
Conversation
src/pages/home/ReportScreen.js
Outdated
| // When a new DM is opened simultaneously from 2 accounts, there'll be 2 different optimistic reports & OpenReport calls | ||
| // The latter will contain preexistingReportID of the initial report and thus is invalid. | ||
| if (_.has(this.props.report, 'preexistingReportID') && !_.has(prevProps.report, 'preexistingReportID')) { | ||
| Report.deleteReport(onyxReportID); | ||
| Navigation.goBack(); | ||
| const preexistingReportID = lodashGet(this.props.report, 'preexistingReportID'); | ||
| Navigation.navigate(ROUTES.getReportRoute(preexistingReportID)); | ||
| this.setState({isReportRemoved: true}); | ||
| return; | ||
| } |
There was a problem hiding this comment.
@tienifr I think we can update the next block, the code doesn’t look dry. I don't think we need to check for prevProps.report.preexistingReportID, we just have to redirect once there is preexistingReportID , can be update to :
const preexistingReportID = lodashGet(this.props.report, 'preexistingReportID', false);
if ((...) || preexistingReportID) {
Navigation.goBack();
if (preexistingReportID){
Report.deleteReport(onyxReportID);
Navigation.navigate(ROUTES.getReportRoute(preexistingReportID));
} else {
Report.navigateToConciergeChat();
}
// isReportRemoved will prevent <FullPageNotFoundView> showing when navigating
this.setState({isReportRemoved: true});
return;
}|
@fedirjh It might flicker when navigating from the invalid to the valid report. Is it acceptable? mweb.mp4 |
@tienifr What do you mean by flicker? It just displays the skeleton view which is the intended behavior, No? |
|
@fedirjh Great! I was a little bit worried about that skeleton effect. But I think it's expected as well. |
Yes, the |
|
@tienifr For offline tests, we can test the scenario when user 1 is online and user 2 is offline and they start a discussion, for this case, it should redirect to the existing report when user 2 goes online. |
src/pages/home/ReportScreen.js
Outdated
| Report.deleteReport(onyxReportID); | ||
| Navigation.navigate(ROUTES.getReportRoute(preexistingReportID)); |
There was a problem hiding this comment.
Let's reverse the order here.
|
@tienifr I got this error on IOS Native, the report shown in the screenshot is the
|
|
We got some conflicts as well. |
Reviewer Checklist
Screenshots/VideosWebCleanShot.2023-08-09.at.13.27.43.mp4Mobile Web - ChromeCleanShot.2023-08-09.at.16.43.46.mp4Mobile Web - SafariCleanShot.2023-08-09.at.16.22.33.mp4DesktopCleanShot.2023-08-09.at.16.18.57.mp4iOSCleanShot.2023-08-09.at.16.25.47.mp4AndroidCleanShot.2023-08-09.at.17.03.53.mp4 |
|
cc @tienifr, the code looks good and tests well however, we still have this console error on native |
|
I'm working on that. But seems hard to find RCA. |
…two-report-screens-open-when-open-report-with-each-other-simultaneously
|
That make sense, let's hold. |
…two-report-screens-open-when-open-report-with-each-other-simultaneously
|
@fedirjh After pulling I think we're good to revert the changes and close this one out 👐👐. |
|
I think it makes sense to close this PR, #24320 seems to have fixed this case. cc @NikkiWines 🎀 👀 🎀 C+ reviewed |
|
Cool! Sounds like this is no longer needed, closing! |

Details
When two users first open the same DM simultaneously, two new reports are opened on each account, one of them is invalid. This PR fixes that.
Fixed Issues
$ #23437
PROPOSAL: #23437 (comment)
Tests
Precondition: A and B have never chat before.
Offline tests
NA
QA Steps
Precondition: A and B have never chat before.
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
Web
Untitled-compressed.mov
Mobile Web - Chrome
mweb.mp4
Mobile Web - Safari
Screen.Recording.2023-08-09.at.02.51.50.mov
Desktop
desktop-compressed.mov
iOS
Screen.Recording.2023-08-09.at.02.48.25.mov
Android
Screen.Recording.2023-08-09.at.03.11.20.mov