From b340f675d0a24dba6149077da20559a10fb71e32 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Mon, 29 Sep 2025 14:46:08 +0800 Subject: [PATCH 1/2] fix missing message sender because the previous message is included but not rendered --- src/libs/ReportActionsUtils.ts | 7 ++++++ src/libs/SearchUIUtils.ts | 3 +++ tests/unit/ReportActionsUtilsTest.ts | 36 ++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 43e826a9f84f..88b297d90d1d 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -864,6 +864,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 34af6dab6c10..8e7caafbed63 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -79,10 +79,12 @@ import { isMoneyRequestAction, isResolvedActionableWhisper, isWhisperActionTargetedToOthers, + shouldReportActionBeVisible, } from './ReportActionsUtils'; import {canReview} from './ReportPreviewActionUtils'; import {isExportAction} from './ReportPrimaryActionUtils'; import { + canUserPerformWriteAction, getIcons, getPersonalDetailsForAccountID, getReportName, @@ -1315,6 +1317,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 54e835ce9544..fac92eb46f90 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -1380,4 +1380,40 @@ describe('ReportActionsUtils', () => { }); }); }); + + describe('shouldReportActionBeVisible', () => { + it('should return false for MOVEDTRANSACTION if the report destination is unavailable', () => { + // Given a MOVEDTRANSACTION 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 MOVEDTRANSACTION if the report destination is available', async () => { + // Given a MOVEDTRANSACTION 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); + }); + }); }); From 4068cd2fc62cd1abf092c5f20244ebfc92fc82f7 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Mon, 29 Sep 2025 15:04:08 +0800 Subject: [PATCH 2/2] fix spelling --- tests/unit/ReportActionsUtilsTest.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts index fac92eb46f90..2b3880a9cbb2 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -1382,8 +1382,8 @@ describe('ReportActionsUtils', () => { }); describe('shouldReportActionBeVisible', () => { - it('should return false for MOVEDTRANSACTION if the report destination is unavailable', () => { - // Given a MOVEDTRANSACTION action but the report destination is not available + 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', @@ -1398,8 +1398,8 @@ describe('ReportActionsUtils', () => { expect(actual).toBe(false); }); - it('should return true for MOVEDTRANSACTION if the report destination is available', async () => { - // Given a MOVEDTRANSACTION action but the report destination is available + 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 = {