Skip to content

Commit 1941639

Browse files
Merge pull request Expensify#85679 from s77rt/log-report-not-found
[No QA] Log report not found
2 parents 613baf8 + 817dbd1 commit 1941639

2 files changed

Lines changed: 71 additions & 45 deletions

File tree

src/pages/Search/SearchMoneyRequestReportPage.tsx

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {PortalHost} from '@gorhom/portal';
22
import {useIsFocused} from '@react-navigation/native';
3-
import React, {useCallback, useEffect, useMemo, useRef} from 'react';
3+
import React, {useEffect, useMemo, useRef} from 'react';
44
import {InteractionManager} from 'react-native';
5-
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
5+
import type {OnyxCollection} from 'react-native-onyx';
66
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
77
import DragAndDropProvider from '@components/DragAndDrop/Provider';
88
import MoneyRequestReportView from '@components/MoneyRequestReportView/MoneyRequestReportView';
@@ -39,15 +39,14 @@ import {
3939
import {isMoneyRequestReport, isMoneyRequestReportPendingDeletion, isValidReportIDFromPath} from '@libs/ReportUtils';
4040
import {cancelSpansByPrefix} from '@libs/telemetry/activeSpans';
4141
import {doesDeleteNavigateBackUrlIncludeDuplicatesReview, getParentReportActionDeletionStatus, hasLoadedReportActions, isThreadReportDeleted} from '@libs/TransactionNavigationUtils';
42-
import {isDefaultAvatar, isLetterAvatar, isPresetAvatar} from '@libs/UserAvatarUtils';
4342
import Navigation from '@navigation/Navigation';
4443
import ReactionListWrapper from '@pages/inbox/ReactionListWrapper';
4544
import {ActionListContext} from '@pages/inbox/ReportScreenContext';
4645
import {clearDeleteTransactionNavigateBackUrl, createTransactionThreadReport, openReport, updateLastVisitTime} from '@userActions/Report';
4746
import CONST from '@src/CONST';
4847
import ONYXKEYS from '@src/ONYXKEYS';
4948
import SCREENS from '@src/SCREENS';
50-
import type {PersonalDetailsList, Policy, Transaction, TransactionViolations} from '@src/types/onyx';
49+
import type {Policy, Transaction, TransactionViolations} from '@src/types/onyx';
5150
import {getEmptyObject} from '@src/types/utils/EmptyObject';
5251

5352
type SearchMoneyRequestPageProps =
@@ -106,7 +105,7 @@ function SearchMoneyRequestReportPage({route}: SearchMoneyRequestPageProps) {
106105
}
107106
Navigation.dismissModal();
108107
}
109-
}, [report]);
108+
}, [report, isFocused, prevReport]);
110109

111110
useEffect(() => {
112111
// Update last visit time when the expense super wide RHP report is focused
@@ -170,22 +169,6 @@ function SearchMoneyRequestReportPage({route}: SearchMoneyRequestPageProps) {
170169
parentReportMetadata,
171170
isOffline,
172171
});
173-
const ownerAccountID = report?.ownerAccountID;
174-
const ownerPersonalDetailsSelector = useCallback(
175-
(personalDetailsList: OnyxEntry<PersonalDetailsList>) => {
176-
if (!ownerAccountID) {
177-
return undefined;
178-
}
179-
180-
return personalDetailsList?.[ownerAccountID];
181-
},
182-
[ownerAccountID],
183-
);
184-
const [ownerPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: ownerPersonalDetailsSelector}, [ownerAccountID]);
185-
const doesOwnerHavePersonalDetails = !!ownerPersonalDetails;
186-
const doesOwnerHaveAvatar = !!ownerPersonalDetails?.avatar;
187-
const doesOwnerHaveDefaultAvatar =
188-
isDefaultAvatar(ownerPersonalDetails?.avatar) || isPresetAvatar(ownerPersonalDetails?.avatar) || isLetterAvatar(ownerPersonalDetails?.originalFileName);
189172

190173
// Prevents creating duplicate transaction threads for legacy transactions
191174
const hasCreatedLegacyThreadRef = useRef(false);
@@ -361,39 +344,35 @@ function SearchMoneyRequestReportPage({route}: SearchMoneyRequestPageProps) {
361344
isThreadReportDeletedForReview,
362345
]);
363346

364-
const prevShouldShowAccessErrorPage = usePrevious(shouldShowAccessErrorPage);
365-
const participantCount = Object.keys(report?.participants ?? {}).length;
366-
367347
useEffect(() => {
368-
if (!shouldShowAccessErrorPage || prevShouldShowAccessErrorPage) {
348+
if (!shouldShowAccessErrorPage) {
369349
return;
370350
}
371351

372-
Log.info('[SearchMoneyRequestReportPage] shouldShowAccessErrorPage changed to true', false, {
373-
reportIDFromRoute,
352+
Log.info('[SearchMoneyRequestReportPage] Displaying NotFound Page', false, {
374353
reportID,
354+
hasLoadedReportActionsForAccessError,
375355
doesReportIDLookValid,
376-
isLoadingApp,
377-
isLoadingInitialReportActions: reportMetadata?.isLoadingInitialReportActions,
378-
ownerAccountID,
379-
doesOwnerHavePersonalDetails,
380-
doesOwnerHaveAvatar,
381-
doesOwnerHaveDefaultAvatar,
382-
participantCount,
356+
isReportPendingDeletion,
357+
wereAllTransactionsDeleted,
358+
hasAnyTransactions,
359+
deleteTransactionNavigateBackUrl,
360+
wasParentActionDeleted,
361+
isThreadReportDeletedForReview,
362+
shouldUseSnapshotTransaction,
383363
});
384364
}, [
385-
doesOwnerHaveAvatar,
386-
doesOwnerHaveDefaultAvatar,
387-
doesOwnerHavePersonalDetails,
388-
doesReportIDLookValid,
389-
isLoadingApp,
390-
ownerAccountID,
391-
participantCount,
392-
prevShouldShowAccessErrorPage,
393-
reportID,
394-
reportIDFromRoute,
395-
reportMetadata?.isLoadingInitialReportActions,
396365
shouldShowAccessErrorPage,
366+
reportID,
367+
hasLoadedReportActionsForAccessError,
368+
doesReportIDLookValid,
369+
isReportPendingDeletion,
370+
wereAllTransactionsDeleted,
371+
hasAnyTransactions,
372+
deleteTransactionNavigateBackUrl,
373+
wasParentActionDeleted,
374+
isThreadReportDeletedForReview,
375+
shouldUseSnapshotTransaction,
397376
]);
398377

399378
return (

src/pages/inbox/ReportScreen.tsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,53 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
531531
isDeletedTransactionThread,
532532
]);
533533

534+
useEffect(() => {
535+
if (!shouldShowNotFoundPage) {
536+
return;
537+
}
538+
539+
Log.info('[ReportScreen] Displaying NotFound Page', false, {
540+
shouldShowNotFoundLinkedAction,
541+
isLoadingApp,
542+
isLoadingReportData,
543+
isOffline,
544+
isLoadingInitialReportActions: reportMetadata?.isLoadingInitialReportActions,
545+
reportID,
546+
isOptimisticDelete,
547+
userLeavingStatus,
548+
currentReportIDFormRoute,
549+
firstRender,
550+
deleteTransactionNavigateBackUrl,
551+
isDeletedTransactionThread,
552+
isParentActionDeleted,
553+
isParentActionMissingAfterLoad,
554+
isNavigatingToDeletedAction,
555+
isLinkedActionInaccessibleWhisper,
556+
isLinkedActionDeleted,
557+
isLinkingToMessage,
558+
});
559+
}, [
560+
shouldShowNotFoundPage,
561+
shouldShowNotFoundLinkedAction,
562+
isLoadingApp,
563+
isLoadingReportData,
564+
isOffline,
565+
reportMetadata?.isLoadingInitialReportActions,
566+
reportID,
567+
isOptimisticDelete,
568+
userLeavingStatus,
569+
currentReportIDFormRoute,
570+
firstRender,
571+
deleteTransactionNavigateBackUrl,
572+
isDeletedTransactionThread,
573+
isParentActionDeleted,
574+
isParentActionMissingAfterLoad,
575+
isNavigatingToDeletedAction,
576+
isLinkedActionInaccessibleWhisper,
577+
isLinkedActionDeleted,
578+
isLinkingToMessage,
579+
]);
580+
534581
const createOneTransactionThreadReport = useCallback(() => {
535582
const currentReportTransaction = getReportTransactions(reportID).filter((transaction) => transaction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);
536583
const oneTransactionID = currentReportTransaction.at(0)?.transactionID;

0 commit comments

Comments
 (0)