From 8eb8bd23a94b89fa159f08537cc5117d53e54968 Mon Sep 17 00:00:00 2001 From: Jakub Korytko Date: Wed, 14 May 2025 12:11:08 +0200 Subject: [PATCH 1/3] Filter out hidden report previews --- .../MoneyRequestReportView/MoneyRequestReportView.tsx | 6 ++++-- src/pages/home/ReportScreen.tsx | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx index 23b0117801c39..15ceb2032ab36 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx @@ -18,7 +18,7 @@ import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID'; import Log from '@libs/Log'; import {selectAllTransactionsForReport, shouldDisplayReportTableView} from '@libs/MoneyRequestReportUtils'; import navigationRef from '@libs/Navigation/navigationRef'; -import {getOneTransactionThreadReportID, isMoneyRequestAction} from '@libs/ReportActionsUtils'; +import {getOneTransactionThreadReportID, isMoneyRequestAction, isReportPreviewAction} from '@libs/ReportActionsUtils'; import {canEditReportAction, getReportOfflinePendingActionAndErrors, isReportTransactionThread} from '@libs/ReportUtils'; import {buildCannedSearchQuery} from '@libs/SearchQueryUtils'; import Navigation from '@navigation/Navigation'; @@ -95,7 +95,9 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe const [isComposerFullSize] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE}${reportID}`, {initialValue: false, canBeMissing: true}); const {reportPendingAction, reportErrors} = getReportOfflinePendingActionAndErrors(report); - const {reportActions, hasNewerActions, hasOlderActions} = usePaginatedReportActions(reportID); + const {reportActions: unfilteredReportActions, hasNewerActions, hasOlderActions} = usePaginatedReportActions(reportID); + const reportActions = unfilteredReportActions.filter((action) => !isReportPreviewAction(action) || action.shouldShow); + const transactionThreadReportID = getOneTransactionThreadReportID(reportID, reportActions ?? [], isOffline); const [transactions = []] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, { diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 73691c688b158..95715d99440bf 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -46,6 +46,7 @@ import { isCreatedAction, isDeletedParentAction, isMoneyRequestAction, + isReportPreviewAction, isWhisperAction, shouldReportActionBeVisible, } from '@libs/ReportActionsUtils'; @@ -272,7 +273,8 @@ function ReportScreen({route, navigation}: ReportScreenProps) { const [currentUserAccountID = -1] = useOnyx(ONYXKEYS.SESSION, {selector: (value) => value?.accountID, canBeMissing: false}); const [currentUserEmail] = useOnyx(ONYXKEYS.SESSION, {selector: (value) => value?.email, canBeMissing: false}); const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true}); - const {reportActions, linkedAction, sortedAllReportActions, hasNewerActions, hasOlderActions} = usePaginatedReportActions(reportID, reportActionIDFromRoute); + const {reportActions: unfilteredReportActions, linkedAction, sortedAllReportActions, hasNewerActions, hasOlderActions} = usePaginatedReportActions(reportID, reportActionIDFromRoute); + const reportActions = unfilteredReportActions.filter((action) => !isReportPreviewAction(action) || action.shouldShow); const [isBannerVisible, setIsBannerVisible] = useState(true); const [scrollPosition, setScrollPosition] = useState({}); From 7a42c3c3bab8c890a8f0e61f9b92c19f3b67c4cd Mon Sep 17 00:00:00 2001 From: Jakub Korytko Date: Wed, 14 May 2025 19:26:52 +0200 Subject: [PATCH 2/3] Re-run reassure From 26923a745dc0d946f33dbddbbb2c586cc562aba6 Mon Sep 17 00:00:00 2001 From: Jakub Korytko Date: Thu, 15 May 2025 10:56:40 +0200 Subject: [PATCH 3/3] Extract filtering to a function --- .../MoneyRequestReportView/MoneyRequestReportView.tsx | 4 ++-- src/libs/ReportActionsUtils.ts | 10 ++++++++++ src/pages/home/ReportScreen.tsx | 4 ++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx index 45d6e39919a19..64c2c890146d9 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportView.tsx @@ -18,7 +18,7 @@ import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID'; import Log from '@libs/Log'; import {selectAllTransactionsForReport, shouldDisplayReportTableView} from '@libs/MoneyRequestReportUtils'; import navigationRef from '@libs/Navigation/navigationRef'; -import {getOneTransactionThreadReportID, isDeletedParentAction, isMoneyRequestAction, isReportPreviewAction} from '@libs/ReportActionsUtils'; +import {getFilteredReportActionsForReportView, getOneTransactionThreadReportID, isMoneyRequestAction} from '@libs/ReportActionsUtils'; import {canEditReportAction, getReportOfflinePendingActionAndErrors, isReportTransactionThread} from '@libs/ReportUtils'; import {buildCannedSearchQuery} from '@libs/SearchQueryUtils'; import Navigation from '@navigation/Navigation'; @@ -96,7 +96,7 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe const {reportPendingAction, reportErrors} = getReportOfflinePendingActionAndErrors(report); const {reportActions: unfilteredReportActions, hasNewerActions, hasOlderActions} = usePaginatedReportActions(reportID); - const reportActions = unfilteredReportActions.filter((action) => !isDeletedParentAction(action) && (!isReportPreviewAction(action) || action.shouldShow)); + const reportActions = getFilteredReportActionsForReportView(unfilteredReportActions); const transactionThreadReportID = getOneTransactionThreadReportID(reportID, reportActions ?? [], isOffline); diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 25aa61f87b3ea..55f4aa483d1e7 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1012,6 +1012,15 @@ function filterOutDeprecatedReportActions(reportActions: OnyxEntry entry[1]); } +/** + * Helper for filtering out Report Actions that are either: + * - ReportPreview with shouldShow set to false + * - Action with parent action deleted + */ +function getFilteredReportActionsForReportView(actions: ReportAction[]) { + return actions.filter((action) => !isDeletedParentAction(action) && (!isReportPreviewAction(action) || action.shouldShow)); +} + /** * This method returns the report actions that are ready for display in the ReportActionsView. * The report actions need to be sorted by created timestamp first, and reportActionID second @@ -2533,6 +2542,7 @@ export { getRemovedConnectionMessage, getActionableJoinRequestPendingReportAction, getReportActionsLength, + getFilteredReportActionsForReportView, wasMessageReceivedWhileOffline, shouldShowAddMissingDetails, getJoinRequestMessage, diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index a491f1c8154d3..536997bad08db 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -40,11 +40,11 @@ import {getPersonalDetailsForAccountIDs} from '@libs/OptionsListUtils'; import {getDisplayNameOrDefault} from '@libs/PersonalDetailsUtils'; import { getCombinedReportActions, + getFilteredReportActionsForReportView, getOneTransactionThreadReportID, isCreatedAction, isDeletedParentAction, isMoneyRequestAction, - isReportPreviewAction, isWhisperAction, shouldReportActionBeVisible, } from '@libs/ReportActionsUtils'; @@ -268,7 +268,7 @@ function ReportScreen({route, navigation}: ReportScreenProps) { const [currentUserEmail] = useOnyx(ONYXKEYS.SESSION, {selector: (value) => value?.email, canBeMissing: false}); const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true}); const {reportActions: unfilteredReportActions, linkedAction, sortedAllReportActions, hasNewerActions, hasOlderActions} = usePaginatedReportActions(reportID, reportActionIDFromRoute); - const reportActions = unfilteredReportActions.filter((action) => !isDeletedParentAction(action) && (!isReportPreviewAction(action) || action.shouldShow)); + const reportActions = getFilteredReportActionsForReportView(unfilteredReportActions); const [isBannerVisible, setIsBannerVisible] = useState(true); const [scrollPosition, setScrollPosition] = useState({});