Skip to content

Commit

Permalink
Merge pull request #38856 from Expensify/Rory-404FlashOnSignIn
Browse files Browse the repository at this point in the history
Don't show 404 on ReportScreen if isLoading is true

(cherry picked from commit 15d993d)
  • Loading branch information
deetergp authored and OSBotify committed Mar 25, 2024
1 parent 20eaba2 commit cd12678
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ function ReportScreen({
const hasHelpfulErrors = Object.keys(report?.errorFields ?? {}).some((key) => key !== 'notFound');
const shouldHideReport = !hasHelpfulErrors && !ReportUtils.canAccessReport(report, policies, betas);

const isLoading = !reportIDFromRoute || !isSidebarLoaded || PersonalDetailsUtils.isPersonalDetailsEmpty();
const lastReportAction: OnyxEntry<OnyxTypes.ReportAction> = useMemo(
() =>
reportActions.length
Expand Down Expand Up @@ -331,14 +330,28 @@ function ReportScreen({
return reportIDFromRoute !== '' && !!report.reportID && !isTransitioning;
}, [report, reportIDFromRoute]);

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 = 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 Expand Up @@ -528,21 +541,6 @@ function ReportScreen({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

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

const actionListValue = useMemo((): ActionListContextType => ({flatListRef, scrollPosition, setScrollPosition}), [flatListRef, scrollPosition, setScrollPosition]);

// This helps in tracking from the moment 'route' triggers useMemo until isLoadingInitialReportActions becomes true. It prevents blinking when loading reportActions from cache.
Expand Down

0 comments on commit cd12678

Please sign in to comment.