Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/components/Search/SearchLoadingSkeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import CONST from '@src/CONST';

type SearchLoadingSkeletonProps = {
containerStyle?: StyleProp<ViewStyle>;
reasonAttributes?: SkeletonSpanReasonAttributes;
reasonAttributes: SkeletonSpanReasonAttributes;
};

function SearchLoadingSkeleton({containerStyle, reasonAttributes}: SearchLoadingSkeletonProps) {
Expand Down
69 changes: 24 additions & 45 deletions src/pages/Search/SearchMoneyRequestReportPage.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {PortalHost} from '@gorhom/portal';
import {useIsFocused} from '@react-navigation/native';
import React, {useCallback, useEffect, useMemo, useRef} from 'react';
import React, {useEffect, useMemo, useRef} from 'react';
import {InteractionManager} from 'react-native';
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import type {OnyxCollection} from 'react-native-onyx';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import DragAndDropProvider from '@components/DragAndDrop/Provider';
import MoneyRequestReportView from '@components/MoneyRequestReportView/MoneyRequestReportView';
Expand Down Expand Up @@ -39,15 +39,14 @@ import {
import {isMoneyRequestReport, isMoneyRequestReportPendingDeletion, isValidReportIDFromPath} from '@libs/ReportUtils';
import {cancelSpansByPrefix} from '@libs/telemetry/activeSpans';
import {doesDeleteNavigateBackUrlIncludeDuplicatesReview, getParentReportActionDeletionStatus, hasLoadedReportActions, isThreadReportDeleted} from '@libs/TransactionNavigationUtils';
import {isDefaultAvatar, isLetterAvatar, isPresetAvatar} from '@libs/UserAvatarUtils';
import Navigation from '@navigation/Navigation';
import ReactionListWrapper from '@pages/inbox/ReactionListWrapper';
import {ActionListContext} from '@pages/inbox/ReportScreenContext';
import {clearDeleteTransactionNavigateBackUrl, createTransactionThreadReport, openReport, updateLastVisitTime} from '@userActions/Report';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import SCREENS from '@src/SCREENS';
import type {PersonalDetailsList, Policy, Transaction, TransactionViolations} from '@src/types/onyx';
import type {Policy, Transaction, TransactionViolations} from '@src/types/onyx';
import {getEmptyObject} from '@src/types/utils/EmptyObject';

type SearchMoneyRequestPageProps =
Expand Down Expand Up @@ -106,7 +105,7 @@ function SearchMoneyRequestReportPage({route}: SearchMoneyRequestPageProps) {
}
Navigation.dismissModal();
}
}, [report]);
}, [report, isFocused, prevReport]);

useEffect(() => {
// Update last visit time when the expense super wide RHP report is focused
Expand Down Expand Up @@ -183,22 +182,6 @@ function SearchMoneyRequestReportPage({route}: SearchMoneyRequestPageProps) {
parentReportMetadata,
isOffline,
});
const ownerAccountID = report?.ownerAccountID;
const ownerPersonalDetailsSelector = useCallback(
(personalDetailsList: OnyxEntry<PersonalDetailsList>) => {
if (!ownerAccountID) {
return undefined;
}

return personalDetailsList?.[ownerAccountID];
},
[ownerAccountID],
);
const [ownerPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: ownerPersonalDetailsSelector}, [ownerAccountID]);
const doesOwnerHavePersonalDetails = !!ownerPersonalDetails;
const doesOwnerHaveAvatar = !!ownerPersonalDetails?.avatar;
const doesOwnerHaveDefaultAvatar =
isDefaultAvatar(ownerPersonalDetails?.avatar) || isPresetAvatar(ownerPersonalDetails?.avatar) || isLetterAvatar(ownerPersonalDetails?.originalFileName);

// Prevents creating duplicate transaction threads for legacy transactions
const hasCreatedLegacyThreadRef = useRef(false);
Expand Down Expand Up @@ -374,39 +357,35 @@ function SearchMoneyRequestReportPage({route}: SearchMoneyRequestPageProps) {
isThreadReportDeletedForReview,
]);

const prevShouldShowAccessErrorPage = usePrevious(shouldShowAccessErrorPage);
const participantCount = Object.keys(report?.participants ?? {}).length;

useEffect(() => {
if (!shouldShowAccessErrorPage || prevShouldShowAccessErrorPage) {
if (!shouldShowAccessErrorPage) {
return;
}

Log.info('[SearchMoneyRequestReportPage] shouldShowAccessErrorPage changed to true', false, {
reportIDFromRoute,
Log.info('[SearchMoneyRequestReportPage] Displaying NotFound Page', false, {
reportID,
hasLoadedReportActionsForAccessError,
doesReportIDLookValid,
isLoadingApp,
isLoadingInitialReportActions: reportMetadata?.isLoadingInitialReportActions,
ownerAccountID,
doesOwnerHavePersonalDetails,
doesOwnerHaveAvatar,
doesOwnerHaveDefaultAvatar,
participantCount,
isReportPendingDeletion,
wereAllTransactionsDeleted,
hasAnyTransactions,
deleteTransactionNavigateBackUrl,
wasParentActionDeleted,
isThreadReportDeletedForReview,
shouldUseSnapshotTransaction,
});
}, [
doesOwnerHaveAvatar,
doesOwnerHaveDefaultAvatar,
doesOwnerHavePersonalDetails,
doesReportIDLookValid,
isLoadingApp,
ownerAccountID,
participantCount,
prevShouldShowAccessErrorPage,
reportID,
reportIDFromRoute,
reportMetadata?.isLoadingInitialReportActions,
shouldShowAccessErrorPage,
reportID,
hasLoadedReportActionsForAccessError,
doesReportIDLookValid,
isReportPendingDeletion,
wereAllTransactionsDeleted,
hasAnyTransactions,
deleteTransactionNavigateBackUrl,
wasParentActionDeleted,
isThreadReportDeletedForReview,
shouldUseSnapshotTransaction,
]);

return (
Expand Down
47 changes: 47 additions & 0 deletions src/pages/inbox/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,53 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
isDeletedTransactionThread,
]);

useEffect(() => {
if (!shouldShowNotFoundPage) {
return;
}

Log.info('[ReportScreen] Displaying NotFound Page', false, {
shouldShowNotFoundLinkedAction,
isLoadingApp,
isLoadingReportData,
isOffline,
isLoadingInitialReportActions: reportMetadata?.isLoadingInitialReportActions,
reportID,
isOptimisticDelete,
userLeavingStatus,
currentReportIDFormRoute,
firstRender,
deleteTransactionNavigateBackUrl,
isDeletedTransactionThread,
isParentActionDeleted,
isParentActionMissingAfterLoad,
isNavigatingToDeletedAction,
isLinkedActionInaccessibleWhisper,
isLinkedActionDeleted,
isLinkingToMessage,
});
}, [
shouldShowNotFoundPage,
shouldShowNotFoundLinkedAction,
isLoadingApp,
isLoadingReportData,
isOffline,
reportMetadata?.isLoadingInitialReportActions,
reportID,
isOptimisticDelete,
userLeavingStatus,
currentReportIDFormRoute,
firstRender,
deleteTransactionNavigateBackUrl,
isDeletedTransactionThread,
isParentActionDeleted,
isParentActionMissingAfterLoad,
isNavigatingToDeletedAction,
isLinkedActionInaccessibleWhisper,
isLinkedActionDeleted,
isLinkingToMessage,
]);

const createOneTransactionThreadReport = useCallback(() => {
const currentReportTransaction = getReportTransactions(reportID).filter((transaction) => transaction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);
const oneTransactionID = currentReportTransaction.at(0)?.transactionID;
Expand Down
Loading