-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix leaving room a room when the split bill with multiple participants #23051
Conversation
@allroundexperts 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] |
@allroundexperts I've proposed this PR to fix the regression. I think we have to scope the logic to only a report that can be left, the additional logic is adapted from here: App/src/pages/ReportDetailsPage.js Line 114 in 5a07bc0
Please let me know your thoughts |
// We scope it to only reports that can be left. | ||
// The nested "if" is intentional and aimed at improving performance. | ||
const policy = prevProps.policies[`${ONYXKEYS.COLLECTION.POLICY}${prevProps.report.policyID}`]; | ||
const isThread = ReportUtils.isChatThread(prevProps.report); | ||
const isUserCreatedPolicyRoom = ReportUtils.isUserCreatedPolicyRoom(prevProps.report); | ||
const canLeaveRoom = ReportUtils.canLeaveRoom(prevProps.report, !_.isEmpty(policy)); | ||
|
||
if (isUserCreatedPolicyRoom || canLeaveRoom || isThread) { | ||
Navigation.goBack(); | ||
Report.navigateToConciergeChat(); | ||
// isReportRemoved will prevent <FullPageNotFoundView> showing when navigating | ||
this.setState({isReportRemoved: true}); | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wildan-m This isn't making full sense to me.
Why can't we replace all this with:
if (prevOnyxReportID && !onyxReportID) {
Navigation.goBack();
Report.navigateToConciergeChat();
// isReportRemoved will prevent <FullPageNotFoundView> showing when navigating
this.setState({isReportRemoved: true});
return;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we replace all this with:
if (prevOnyxReportID && !onyxReportID) {
@allroundexperts Known issue using only that check is when we split the bill and re-join the public room right after we leave it. as I described earlier, it's tricky to determine if a report is removed. when we remove a report from device A, then device B will get this response from the pusher
[
{
"eventType": "onyxApiUpdate",
"data": [
{
"onyxMethod": "set",
"key": "report_7794307233155968",
"value": null
}
]
}
]
The response will completely remove the props.report
and make props.reprot
equal to defaultProps.report
Here is the tricky part. props.report.reportID === null
or _.isEqual(props.report, defaultProps.report)
doesn't always mean a report is removed It can also mean:
- User is navigating to another report
- Onyx data for that report is not ready
Since we have a massive call of openReport
, then the concurrent situation can happen, there is a chance that a openReport
call already filled props.report
but another concurrent openReport (e.g when loading report actions, or updateing lastReadReport) thinks props.report
is not ready and then in componentDidUpdate condition prevOnyxReportID && !onyxReportID
will be true.
In summary, since this ReportScreen
is being used by other pages other than the room, then unexpected situations can happen.
Why scoping the condition works?
It actually minimizes the unexpected error, currently, we can't leave split bill chat, so our navigateToConcierge will not be executed.
Is there any other solution?
Yes, if we can modify the backend to send this value instead of null then we can exactly determine isReportRemoved
condition and remove the remaining onyx data of a report from the front end. CONST.REPORT.STATUS.REMOVED
is a new value, since CONST.REPORT.STATUS.CLOSED
can also mean that the report is archived but not removed
[
{
"eventType": "onyxApiUpdate",
"data": [
{
"onyxMethod": "set",
"key": "report_7794307233155968",
value: {
reportID: 7794307233155968
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
statusNum: CONST.REPORT.STATUS.REMOVED,
},
}
]
}
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wildan-m I'm more inclined with fixing this on the backend. But I think that the backend part is not necessarily a regression. That being said, can you post a video of the bug that arises when using:
if (prevOnyxReportID && !onyxReportID) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@allroundexperts Sure, here is the video
Recording.44.2.mp4
- split bill issue
- re-join the public room right after leaving it. Notice that the issue not always occurred since
openReport
call not always executed concurrently
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the split bill issue, I think even without our changes, its redirecting to a 404 page which is incorrect in its own. Is that correct / do you agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That might be a possibility. I'd recommend we bring this conversation to Slack though so we can get more opinions from the team.
Just a heads up that I'll be ooo until Aug 8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luacmartins, @allroundexperts seems there is no other suggested solution in Slack. can we proceed with this solution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not fully satisfied by the solution being proposed here. But at the same time, it looks as if we're short of options. Give me a day or two to think more about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for starting the discussion in Slack @wildan-m. Let's see what others say about it. I tagged another member of the team to get the conversation going.
Hey @allroundexperts @wildan-m 👋, I was working on this PR and noticed this issue -
User should stay on the same chat. User shouldn't be navigated away. Screen.Recording.2023-07-24.at.1.57.00.AM.movI commented out the code from the original PR and this stopped happening. So, do you also plan to fix this in this PR? From what I investigated Might require a backend change like you both said. |
@Nikhil-Vats will your activities will cancel/discard report creation when an error occurred? If yes then the redirection issue should be resolved once we can distinguish the type of report removal from the backend. @allroundexperts, can we proceed with the backend change? |
@allroundexperts @wildan-m This is the expected behaviour for the issue I am working on, only RHN should close but the user should stay on the same chat. Screen.Recording.2023-07-31.at.8.57.32.AM.mov |
Hey @allroundexperts @wildan-m, is it okay with you if we revert the changes in the original PR so that we can get unblocked on this PR? You can add those changes back in this PR with the correct fix. We discussed it here but wanted to confirm with you. |
That's fine @Nikhil-Vats |
Thanks for the quick confirmation @allroundexperts. |
@allroundexperts I also wanted to confirm if you are also handling this scenario as per your comment here -
We want to stay on the same page after the error but since the whole report is cleared, we are redirected to 404 page. Screen.Recording.2023-08-02.at.21.23.37.movSteps -
Expected - User should stay on the same page, RHN (request money modal) should close and error is shown. This happens on desktop app very frequently, on other platforms this happens sometimes and after a delay. If yes, we will put this issue on hold for this fix. |
@Nikhil-Vats @allroundexperts It seems that 404 has a different root cause and will not be directly fixed here, what we will fix is regression related to navigating to the concierge chat which should only apply after the user leaves a room. (not caused by report creation cancelation) |
Moving here: #24407 |
@johncschuster , @allroundexperts
Details
Fix leaving a room from multiple devices and fix regression when splitting the bill
Fixed Issues
$ #21518
$ #22964
PROPOSAL: #21518 (comment)
Tests
Leave Room
on one of the devices (e.g. web)Offline tests
Leave Room
on one of the devices (e.g. web)QA Steps
Leave Room
on one of the devices (e.g. web)PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
Recording.36.mp4
Mobile Web - Chrome
Recording.35.mp4
Mobile Web - Safari
Recording.40.mp4
Desktop
Recording.40.2.mp4
iOS
Recording.38.mp4
Android
Recording.34.mp4