diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 625b66ee81d8..5760335fb8a3 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -863,6 +863,13 @@ function shouldReportActionBeVisible(reportAction: OnyxEntry, key: return false; } + if (isMovedTransactionAction(reportAction)) { + const movedTransactionOriginalMessage = getOriginalMessage(reportAction); + const toReportID = movedTransactionOriginalMessage?.toReportID; + const toReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${toReportID}`]; + return !!toReport; + } + // Ignore closed action here since we're already displaying a footer that explains why the report was closed if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CLOSED && !isMarkAsClosedAction(reportAction)) { return false; diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index f93e63ae7c74..9d2a5e5a4365 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -81,10 +81,12 @@ import { isMoneyRequestAction, isResolvedActionableWhisper, isWhisperActionTargetedToOthers, + shouldReportActionBeVisible, } from './ReportActionsUtils'; import {canReview} from './ReportPreviewActionUtils'; import {isExportAction} from './ReportPrimaryActionUtils'; import { + canUserPerformWriteAction, getIcons, getPersonalDetailsForAccountID, getReportName, @@ -1326,6 +1328,7 @@ function getReportActionsSections(data: OnyxTypes.SearchResults['data']): Report const invoiceReceiverPolicy: SearchPolicy | undefined = report?.invoiceReceiver?.type === CONST.REPORT.INVOICE_RECEIVER_TYPE.BUSINESS ? data[`${ONYXKEYS.COLLECTION.POLICY}${report.invoiceReceiver.policyID}`] : undefined; if ( + !shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canUserPerformWriteAction(report, isReportArchived)) || isDeletedAction(reportAction) || isResolvedActionableWhisper(reportAction) || reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CLOSED || diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts index 6b829a113c38..00a87c360671 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -1384,6 +1384,42 @@ describe('ReportActionsUtils', () => { }); }); + describe('shouldReportActionBeVisible', () => { + it('should return false for moved transaction if the report destination is unavailable', () => { + // Given a moved transaction action but the report destination is not available + const reportAction: ReportAction = { + actionName: CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION, + reportActionID: '1', + created: '2025-09-29', + originalMessage: { + toReportID: '2', + }, + }; + + // Then the action should not be visible + const actual = ReportActionsUtils.shouldReportActionBeVisible(reportAction, reportAction.reportActionID, true); + expect(actual).toBe(false); + }); + + it('should return true for moved transaction if the report destination is available', async () => { + // Given a moved transaction action but the report destination is available + const report: Report = createRandomReport(2); + await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, report); + const reportAction: ReportAction = { + actionName: CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION, + reportActionID: '1', + created: '2025-09-29', + originalMessage: { + toReportID: report.reportID, + }, + }; + + // Then the action should be visible + const actual = ReportActionsUtils.shouldReportActionBeVisible(reportAction, reportAction.reportActionID, true); + expect(actual).toBe(true); + }); + }); + describe('getPolicyChangeLogUpdateEmployee', () => { it('should remove SMS domain when the email is a phone number', () => { const email = '+919383833920@expensify.sms';