|
1 | 1 | import {PortalHost} from '@gorhom/portal'; |
2 | 2 | import {useIsFocused} from '@react-navigation/native'; |
3 | | -import React, {useCallback, useEffect, useMemo, useRef} from 'react'; |
| 3 | +import React, {useEffect, useMemo, useRef} from 'react'; |
4 | 4 | import {InteractionManager} from 'react-native'; |
5 | | -import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; |
| 5 | +import type {OnyxCollection} from 'react-native-onyx'; |
6 | 6 | import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; |
7 | 7 | import DragAndDropProvider from '@components/DragAndDrop/Provider'; |
8 | 8 | import MoneyRequestReportView from '@components/MoneyRequestReportView/MoneyRequestReportView'; |
@@ -39,15 +39,14 @@ import { |
39 | 39 | import {isMoneyRequestReport, isMoneyRequestReportPendingDeletion, isValidReportIDFromPath} from '@libs/ReportUtils'; |
40 | 40 | import {cancelSpansByPrefix} from '@libs/telemetry/activeSpans'; |
41 | 41 | import {doesDeleteNavigateBackUrlIncludeDuplicatesReview, getParentReportActionDeletionStatus, hasLoadedReportActions, isThreadReportDeleted} from '@libs/TransactionNavigationUtils'; |
42 | | -import {isDefaultAvatar, isLetterAvatar, isPresetAvatar} from '@libs/UserAvatarUtils'; |
43 | 42 | import Navigation from '@navigation/Navigation'; |
44 | 43 | import ReactionListWrapper from '@pages/inbox/ReactionListWrapper'; |
45 | 44 | import {ActionListContext} from '@pages/inbox/ReportScreenContext'; |
46 | 45 | import {clearDeleteTransactionNavigateBackUrl, createTransactionThreadReport, openReport, updateLastVisitTime} from '@userActions/Report'; |
47 | 46 | import CONST from '@src/CONST'; |
48 | 47 | import ONYXKEYS from '@src/ONYXKEYS'; |
49 | 48 | 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'; |
51 | 50 | import {getEmptyObject} from '@src/types/utils/EmptyObject'; |
52 | 51 |
|
53 | 52 | type SearchMoneyRequestPageProps = |
@@ -106,7 +105,7 @@ function SearchMoneyRequestReportPage({route}: SearchMoneyRequestPageProps) { |
106 | 105 | } |
107 | 106 | Navigation.dismissModal(); |
108 | 107 | } |
109 | | - }, [report]); |
| 108 | + }, [report, isFocused, prevReport]); |
110 | 109 |
|
111 | 110 | useEffect(() => { |
112 | 111 | // Update last visit time when the expense super wide RHP report is focused |
@@ -170,22 +169,6 @@ function SearchMoneyRequestReportPage({route}: SearchMoneyRequestPageProps) { |
170 | 169 | parentReportMetadata, |
171 | 170 | isOffline, |
172 | 171 | }); |
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); |
189 | 172 |
|
190 | 173 | // Prevents creating duplicate transaction threads for legacy transactions |
191 | 174 | const hasCreatedLegacyThreadRef = useRef(false); |
@@ -361,39 +344,35 @@ function SearchMoneyRequestReportPage({route}: SearchMoneyRequestPageProps) { |
361 | 344 | isThreadReportDeletedForReview, |
362 | 345 | ]); |
363 | 346 |
|
364 | | - const prevShouldShowAccessErrorPage = usePrevious(shouldShowAccessErrorPage); |
365 | | - const participantCount = Object.keys(report?.participants ?? {}).length; |
366 | | - |
367 | 347 | useEffect(() => { |
368 | | - if (!shouldShowAccessErrorPage || prevShouldShowAccessErrorPage) { |
| 348 | + if (!shouldShowAccessErrorPage) { |
369 | 349 | return; |
370 | 350 | } |
371 | 351 |
|
372 | | - Log.info('[SearchMoneyRequestReportPage] shouldShowAccessErrorPage changed to true', false, { |
373 | | - reportIDFromRoute, |
| 352 | + Log.info('[SearchMoneyRequestReportPage] Displaying NotFound Page', false, { |
374 | 353 | reportID, |
| 354 | + hasLoadedReportActionsForAccessError, |
375 | 355 | 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, |
383 | 363 | }); |
384 | 364 | }, [ |
385 | | - doesOwnerHaveAvatar, |
386 | | - doesOwnerHaveDefaultAvatar, |
387 | | - doesOwnerHavePersonalDetails, |
388 | | - doesReportIDLookValid, |
389 | | - isLoadingApp, |
390 | | - ownerAccountID, |
391 | | - participantCount, |
392 | | - prevShouldShowAccessErrorPage, |
393 | | - reportID, |
394 | | - reportIDFromRoute, |
395 | | - reportMetadata?.isLoadingInitialReportActions, |
396 | 365 | shouldShowAccessErrorPage, |
| 366 | + reportID, |
| 367 | + hasLoadedReportActionsForAccessError, |
| 368 | + doesReportIDLookValid, |
| 369 | + isReportPendingDeletion, |
| 370 | + wereAllTransactionsDeleted, |
| 371 | + hasAnyTransactions, |
| 372 | + deleteTransactionNavigateBackUrl, |
| 373 | + wasParentActionDeleted, |
| 374 | + isThreadReportDeletedForReview, |
| 375 | + shouldUseSnapshotTransaction, |
397 | 376 | ]); |
398 | 377 |
|
399 | 378 | return ( |
|
0 commit comments