Skip to content

Commit

Permalink
Merge pull request Expensify#39377 from Expensify/revert-38955-fix/sh…
Browse files Browse the repository at this point in the history
…ow-404-for-invalid-report

[CP Staging] Revert "fixes "Skeleton is displayed when navigating to a transaction thread created offline""
  • Loading branch information
chiragsalian authored Apr 2, 2024
2 parents 008574a + d2ab32d commit 2175753
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ type ReportScreenProps = ReportScreenPropsWithoutParentReportAction & ReportScre
function getReportID(route: ReportScreenNavigationProps['route']): string {
// The report ID is used in an onyx key. If it's an empty string, onyx will return
// a collection instead of an individual report.
return String(route.params?.reportID || '');
return String(route.params?.reportID || 0);
}

/**
Expand Down Expand Up @@ -349,21 +349,28 @@ function ReportScreen({
return reportIDFromRoute !== '' && !!report.reportID && !isTransitioning;
}, [report, reportIDFromRoute]);

const isLoading = !isSidebarLoaded || PersonalDetailsUtils.isPersonalDetailsEmpty();
const isLoading = !ReportUtils.isValidReportIDFromPath(reportIDFromRoute) || !isSidebarLoaded || PersonalDetailsUtils.isPersonalDetailsEmpty();
const shouldShowSkeleton =
isLinkingToMessage ||
!isCurrentReportLoadedFromOnyx ||
(reportActions.length === 0 && !!reportMetadata?.isLoadingInitialReportActions) ||
isLoading ||
(!!reportActionIDFromRoute && reportMetadata?.isLoadingInitialReportActions);

const shouldShowReportActionList = isCurrentReportLoadedFromOnyx && !isLoading;
// eslint-disable-next-line rulesdir/no-negated-variables
const shouldShowNotFoundPage =
!firstRenderRef.current &&
((!wasReportAccessibleRef.current && !report.reportID && !isOptimisticDelete && !reportMetadata?.isLoadingInitialReportActions && !userLeavingStatus) ||
shouldHideReport ||
(!!reportIDFromRoute && !ReportUtils.isValidReportIDFromPath(reportIDFromRoute)));
const shouldShowNotFoundPage = useMemo(
(): boolean =>
!shouldShowSkeleton &&
((!wasReportAccessibleRef.current &&
!firstRenderRef.current &&
!report.reportID &&
!isOptimisticDelete &&
!reportMetadata?.isLoadingInitialReportActions &&
!userLeavingStatus) ||
shouldHideReport ||
(!!reportIDFromRoute && !ReportUtils.isValidReportIDFromPath(reportIDFromRoute))),
[shouldShowSkeleton, report.reportID, isOptimisticDelete, reportMetadata?.isLoadingInitialReportActions, userLeavingStatus, shouldHideReport, reportIDFromRoute],
);

const fetchReport = useCallback(() => {
Report.openReport(reportIDFromRoute, reportActionIDFromRoute);
Expand Down

0 comments on commit 2175753

Please sign in to comment.