Skip to content
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

[CP Staging] Fixes not found page not being shown properly when not having access to report #28584

Merged
merged 6 commits into from
Oct 2, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 18 additions & 25 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
hasOutstandingIOU: false,
},
reportMetadata: {
isLoadingReportActions: false,
isLoadingReportActions: true,
isLoadingMoreReportActions: false,
},
isComposerFullSize: false,
Expand All @@ -118,15 +118,6 @@
...withCurrentReportIDDefaultProps,
};

/**
*
* Function to check weather the report available in props is default
*
* @param {Object} report
* @returns {Boolean}
*/
const checkDefaultReport = (report) => report === defaultProps.report;

/**
* Get the currently viewed report ID as number
*
Expand Down Expand Up @@ -188,8 +179,6 @@
const isTopMostReportId = currentReportID === getReportID(route);
const didSubscribeToReportLeavingEvents = useRef(false);

const isDefaultReport = checkDefaultReport(report);

let headerView = (
<HeaderView
reportID={reportID}
Expand Down Expand Up @@ -248,11 +237,12 @@
// It possible that we may not have the report object yet in Onyx yet e.g. we navigated to a URL for an accessible report that
// is not stored locally yet. If report.reportID exists, then the report has been stored locally and nothing more needs to be done.
// If it doesn't exist, then we fetch the report from the API.
if (report.reportID && report.reportID === getReportID(route)) {
if (report.reportID && report.reportID === getReportID(route) && !_.isEmpty(reportActions)) {
return;
}

Report.openReport(reportIDFromPath);
}, [report.reportID, route]);

Check warning on line 245 in src/pages/home/ReportScreen.js

View workflow job for this annotation

GitHub Actions / lint

React Hook useCallback has a missing dependency: 'reportActions'. Either include it or remove the dependency array
ospfranco marked this conversation as resolved.
Show resolved Hide resolved

const dismissBanner = useCallback(() => {
setIsBannerVisible(false);
Expand Down Expand Up @@ -364,18 +354,21 @@

// eslint-disable-next-line rulesdir/no-negated-variables
const shouldShowNotFoundPage = useMemo(
() =>
(!firstRenderRef.current &&
!_.isEmpty(report) &&
!isDefaultReport &&
!report.reportID &&
!isOptimisticDelete &&
!report.isLoadingReportActions &&
!isLoading &&
!userLeavingStatus) ||
shouldHideReport,
[report, isLoading, shouldHideReport, isDefaultReport, isOptimisticDelete, userLeavingStatus],
() => (!firstRenderRef.current && !report.reportID && !isOptimisticDelete && !reportMetadata.isLoadingReportActions && !isLoading && !userLeavingStatus) || shouldHideReport,
[report, reportMetadata, isLoading, shouldHideReport, isOptimisticDelete, userLeavingStatus],
);
console.log('Report Screen render');

Check failure on line 360 in src/pages/home/ReportScreen.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

console.log(report);

Check failure on line 362 in src/pages/home/ReportScreen.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

console.table({

Check failure on line 364 in src/pages/home/ReportScreen.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
shouldShowNotFoundPage,
reportId: report.reportID,
isOptimisticDelete,
isLoadingReportActions: reportMetadata.isLoadingReportActions,
isLoading,
userLeavingStatus,
});
ospfranco marked this conversation as resolved.
Show resolved Hide resolved

return (
<ActionListContext.Provider value={flatListRef}>
Expand Down Expand Up @@ -486,7 +479,7 @@
reportMetadata: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_METADATA}${getReportID(route)}`,
initialValue: {
isLoadingReportActions: false,
isLoadingReportActions: true,
isLoadingMoreReportActions: false,
},
},
Expand Down
Loading