-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 crash app when opening split bill detail page by deep link #23977
Conversation
@mananjadhav 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] |
@mananjadhav Friendly bump. |
Reviewing this currently. Will finish this in a few hours. |
forwardedRef: () => {}, | ||
reportActions: {}, | ||
report: { | ||
isLoadingReportActions: true, |
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 do we need isLoadingReportingActions: true
in default props? Why can't we have empty?
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.
Yes I think we can remove this. I add this to verify that this will loading until the API is complete.
|
||
// eslint-disable-next-line rulesdir/no-negated-variables | ||
function WithReportAndReportActionOrNotFound(props) { | ||
// For small screen, we don't call openReport API when we go to a sub report page by deeplinnk |
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'll have to verify this, can you confirm if this is documented somewhere?
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.
If we open a sub report link the app doesn't call openReport API in openReportByDeepLink function. And in small screen, we go to sidebar after login in. That is why it doesn't call openReport API in small screen after login.
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 tested this in small screen without this and it display not found page.
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.
Do you think we should alway call openReport one time here if props.report is empty.
|
||
// eslint-disable-next-line rulesdir/no-negated-variables | ||
function WithReportAndReportActionOrNotFound(props) { | ||
// For small screen, we don't call openReport API when we go to a sub report page by deeplinnk |
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 small screen, we don't call openReport API when we go to a sub report page by deeplinnk | |
// For small screen, we don't call openReport API when we go to a sub report page by deeplink |
key: ONYXKEYS.COLLECTION.POLICY, | ||
}, | ||
reportActions: { | ||
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${route.params.reportID}`, |
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.
Original code explicitly added toString()
. Would this break something if we don't put toString
?
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 think that fine because we wrap it in `` that is a string.
|
||
let reportAction = props.reportActions[`${props.route.params.reportActionID.toString()}`]; | ||
// Handle threads if needed | ||
if (reportAction === undefined || reportAction.reportActionID === undefined) { |
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 think this section can be moved to this own method?
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.
It should be checked here to verify the reportAction is exist or not.
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 am fine, I am saying just move this block to it's own method?
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.
Do you mean we should create a method for 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.
This whole block.
let reportAction = props.reportActions[`${props.route.params.reportActionID.toString()}`];
// Handle threads if needed
if (reportAction === undefined || reportAction.reportActionID === undefined) {
reportAction = ReportActionsUtils.getParentReportAction(props.report);
}
} | ||
}, [props.isSmallScreenWidth, props.route.params.reportID]); | ||
|
||
const isLoadingReport = props.isLoadingReportData && (_.isEmpty(props.report) || !props.report.reportID); |
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 understand these checks are complex, but we generally try to early return. Is it possible to structure the code:
// Perform all the loading checks
const isLoadingReport = ...;
const isLoadingReportAction = ....;
if ((isLoadingReport || isLoadingReportAction) && !shouldHideReport) {
return <FullscreenLoadingIndicator />;
}
// Perform the access/not found checks
const shouldHideReport
if (shouldHideReport || _.isEmpty(reportAction)) {
return <NotFoundPage />;
}
if ((isLoadingReport || isLoadingReportAction) && !shouldHideReport) { | ||
return <FullscreenLoadingIndicator />; | ||
} | ||
if (shouldHideReport || _.isEmpty(reportAction)) { |
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.
Please check my comment above and then I feel shouldHideReport
won't be needed, the conditions can be put here inline.
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 will check and re-test again.
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.
Some reports contain data but we can not access this report by ReportUtils.canAccessReport
fucntion, so this check is necessary to display not found page.
@dukenv0307 I've left some comments, I'll be available to review in another 2-3 hours. |
@mananjadhav Updated for all recommendations above. |
} | ||
Report.openReport(props.route.params.reportID); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); |
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 would we not want to depend on the props.isSmallScreenWdith
and props.report
?
@dukenv0307 1-2 comments and the rest of it looks good. |
// Perform all the loading checks | ||
const isLoadingReport = props.isLoadingReportData && (_.isEmpty(props.report) || !props.report.reportID); | ||
const isLoadingReportAction = _.isEmpty(props.reportActions) || (props.report.isLoadingReportActions && _.isEmpty(getReportAction())); | ||
const shouldHideReport = !isLoadingReport && (_.isEmpty(props.report) || !props.report.reportID || !ReportUtils.canAccessReport(props.report, props.policies, props.betas)); |
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.
Possible to move this check after the return <FullScreenLoadingIndicator>
?
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.
testing again if it's possible
const isLoadingReportAction = _.isEmpty(props.reportActions) || (props.report.isLoadingReportActions && _.isEmpty(getReportAction())); | ||
const shouldHideReport = !isLoadingReport && (_.isEmpty(props.report) || !props.report.reportID || !ReportUtils.canAccessReport(props.report, props.policies, props.betas)); | ||
|
||
if ((isLoadingReport || isLoadingReportAction) && !shouldHideReport) { |
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.
Inline with the above comment, anyway to remove !shouldHideReport
from here so that the flag is only initialized after this block?
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.
This check is necessary here. if reportID is not found props.reportAction
is true
and isLoadingReportAction
is true
, so we need shouldHideReport
here to return false if the report doesn't exist.
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.
Okay thanks.
} | ||
Report.openReport(props.route.params.reportID); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); |
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.
We're only left with this now @dukenv0307? Do we need to disable the exhaustive-deps check? Why not add the props.isSmallScreenWidth
, props.report
, props.route.params.reportID
to the dependencies?
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 think we only need to call this API one time here.
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.
Are we sure?
- What happens when we're on Desktop/Web and resize the browser? and then perform the steps?
- Assume that we've got more than one Split bill requests URL shared on chat, and we click on both one after the other?
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.
Cool will add dependence again.
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.
Updated.
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.
Hey,
Sorry I should've been clear. I am not saying always need to add the dependencies. I wanted to know if it is required? If not, then we add a comment why certain properties are not required.
For example,
- I feel
isSmallScreenWidth
is required - I am not confident about
props.report
? - and I am pretty sure we don't need
route.params.reportID
as that would mean opening a new URL, which should probably reload the whole component, thereby callinguseEffect
Please correct me if I my understanding is wrong? May be you could test at your end?
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.
isSmallScreenWidth and route.param.reportID will be fine because inn native if we already open a split bill and we open other by deeplink maybe this component will not unmount.
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.
@mananjadhav updated, help to check again.
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 @dukenv0307. I'll test this in an hour.
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 addressing the changes. I am now testing this.
Reviewer Checklist
Screenshots/VideosWebweb-split-bill-crash.movMobile Web - Chromemweb-chrome-split-bill-crash.movMobile Web - Safarimweb-safari-split-bill-crash.movDesktopdesktop-split-bill-crash.moviOSios-split-bill-crash.movAndroidandroid-split-bill-crash.mov |
@dukenv0307 This isn't working for me. I thought it was an issue with my account, so I created a new account. It just keeps loading.
This is always true for me. web-report-actions-not-loading.mov |
@mananjadhav You can see the report screen the report doesn't loading completely |
@mananjadhav Can you run |
@mananjadhav Can you check again, I tested and it works as well. In the video above, because the Screencast.from.03-08-2023.00.26.09.webm |
@dukenv0307 There was an issue with the Expensify servers. I thought it was because of the PR, because it loaded on main. Anyway this worked fine on Web, now testing on other platforms. |
Thanks for the patience here @dukenv0307. This tests well. I can we don't link the URLs on native, which exists on the main too. @Li357 All yours. |
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.
LGTM! Thanks y'all for getting this out!
✋ 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/Li357 in version: 1.3.50-0 🚀
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.50-3 🚀
|
🚀 Deployed to staging by https://github.com/Li357 in version: 1.3.51-0 🚀
|
🚀 Deployed to production by https://github.com/Julesssss in version: 1.3.51-2 🚀
|
Details
Fix crash app when opening split bill detail page by deep link
Fixed Issues
$ #23568
PROPOSAL: #23568 (comment)
Tests
Offline tests
Need online to open the app by deep link
QA Steps
--->
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
Note: For native, if we open by deep link before login app still go to LHN after login successfully. So in the video for IOS and Android, we open by deep link after login.
Web
Screen-Recording-2023-08-02-at-10.09.20.mp4
Mobile Web - Chrome
Record_2023-08-01-14-11-45.mp4
Mobile Web - Safari
Screen-Recording-2023-08-01-at-15.22.17.mp4
Desktop
Screen.Recording.2023-08-01.at.12.30.35.mp4
iOS
Screen-Recording-2023-08-01-at-14.22.23.mp4
Android
23568.mp4