From 822c268ac4d64625a0b7d3144d09cabb57e9361b Mon Sep 17 00:00:00 2001 From: truph01 Date: Thu, 24 Jul 2025 15:03:43 +0700 Subject: [PATCH 1/6] fix: Deleted Message displayed on LHN --- src/libs/ReportActionsUtils.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 40d12e88f016..a3c40dac88ac 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -841,6 +841,10 @@ function shouldReportActionBeVisible(reportAction: OnyxEntry, key: return false; } + if (!shouldActionBeVisible(reportAction)) { + return false; + } + // All other actions are displayed except thread parents, deleted, or non-pending actions const isDeleted = isDeletedAction(reportAction); const isPending = !!reportAction.pendingAction; @@ -984,14 +988,24 @@ function filterOutDeprecatedReportActions(reportActions: OnyxEntry isDeletedParentAction(action) && isMoneyRequestAction(action); - const isHiddenReportPreviewWithoutPendingAction = (action: ReportAction) => isReportPreviewAction(action) && action.pendingAction === undefined && !action.shouldShow; - return actions.filter((action) => !isDeletedMoneyRequest(action) && !isHiddenReportPreviewWithoutPendingAction(action)); + return actions.filter(shouldActionBeVisible); } /** From c59175a50357a32b964b9a202b26885bd08d935a Mon Sep 17 00:00:00 2001 From: truph01 Date: Thu, 24 Jul 2025 15:45:04 +0700 Subject: [PATCH 2/6] fix: unit test --- tests/unit/SidebarUtilsTest.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/SidebarUtilsTest.ts b/tests/unit/SidebarUtilsTest.ts index 165bb1b30471..d5ae48b23d98 100644 --- a/tests/unit/SidebarUtilsTest.ts +++ b/tests/unit/SidebarUtilsTest.ts @@ -1015,6 +1015,7 @@ describe('SidebarUtils', () => { childReportID: '5186125925096828', created: '2025-07-10 17:45:31.448', reportActionID: '7425617950691586420', + shouldShow: true, message: [ { type: 'COMMENT', From 701737f8dc4cb9c26a45ca8d9007876d9485feb1 Mon Sep 17 00:00:00 2001 From: truph01 Date: Fri, 25 Jul 2025 15:03:06 +0700 Subject: [PATCH 3/6] fix: add test --- tests/unit/SidebarUtilsTest.ts | 110 +++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/tests/unit/SidebarUtilsTest.ts b/tests/unit/SidebarUtilsTest.ts index d5ae48b23d98..de069853fa08 100644 --- a/tests/unit/SidebarUtilsTest.ts +++ b/tests/unit/SidebarUtilsTest.ts @@ -1322,6 +1322,116 @@ describe('SidebarUtils', () => { expect(result?.alternateText).toBe(`You: ${getReportActionMessageText(lastAction)}`); }); + + it('uses the 2nd-last visible message as alternateText when the latest action is a deleted IOU', async () => { + const MOCK_REPORT: Report = { + reportID: '1', + ownerAccountID: 12345, + chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, + stateNum: CONST.REPORT.STATE_NUM.OPEN, + statusNum: CONST.REPORT.STATUS_NUM.OPEN, + policyID: '6', + }; + + const MOCK_REPORTS: ReportCollectionDataSet = { + [`${ONYXKEYS.COLLECTION.REPORT}${MOCK_REPORT.reportID}` as const]: MOCK_REPORT, + }; + const lastAction: ReportAction = { + ...createRandomReportAction(1), + message: [ + { + type: 'COMMENT', + html: 'test action', + text: 'test action', + }, + ], + originalMessage: { + whisperedTo: [], + }, + + shouldShow: true, + pendingAction: null, + actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, + actorAccountID: undefined, + created: '2025-07-25 07:38:54.211', + }; + const deletedAction: ReportAction = { + ...createRandomReportAction(2), + actionName: 'IOU', + actorAccountID: 20337430, + automatic: false, + isAttachmentOnly: false, + originalMessage: { + amount: 100, + comment: '', + currency: 'VND', + IOUTransactionID: '7823889167761419930', + IOUReportID: '0', + type: 'track', + participantAccountIDs: [20337430, 0], + lastModified: '2025-07-25 07:39:02.550', + deleted: '2025-07-25 07:39:02.550', + html: '', + }, + message: [ + { + type: '', + text: '', + isDeletedParentAction: true, + }, + ], + reportActionID: '869069913568459256', + shouldShow: true, + created: '2025-07-25 07:38:54.311', + person: [ + { + style: 'strong', + text: '123', + type: 'TEXT', + }, + ], + avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_21.png', + childReportID: '3044322706237838', + lastModified: '2025-07-25 07:39:02.550', + childCommenterCount: 1, + childLastVisibleActionCreated: '2025-07-25 07:38:47.598', + childOldestFourAccountIDs: '20337430', + childStateNum: 0, + childStatusNum: 0, + childType: 'chat', + childVisibleActionCount: 1, + timestamp: 1753429134, + reportActionTimestamp: 1753429134311, + whisperedToAccountIDs: [], + childReportNotificationPreference: 'always', + }; + const MOCK_REPORT_ACTIONS: ReportActions = { + // eslint-disable-next-line @typescript-eslint/naming-convention + [lastAction.reportActionID]: lastAction, + [deletedAction.reportActionID]: deletedAction, + }; + + await Onyx.multiSet({ + [ONYXKEYS.SESSION]: { + accountID: 12345, + }, + ...MOCK_REPORTS, + + [`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${MOCK_REPORT.reportID}` as const]: MOCK_REPORT_ACTIONS, + }); + + const result = SidebarUtils.getOptionData({ + report: MOCK_REPORT, + reportAttributes: undefined, + reportNameValuePairs: {}, + personalDetails: {}, + policy: undefined, + parentReportAction: undefined, + oneTransactionThreadReport: undefined, + }); + + expect(result?.alternateText).toContain(`${getReportActionMessageText(lastAction)}`); + }); }); }); }); From 34b1b5c494105a644612fc803b35c62b50469ef4 Mon Sep 17 00:00:00 2001 From: truph01 Date: Mon, 28 Jul 2025 15:53:09 +0700 Subject: [PATCH 4/6] fix: rename function --- src/libs/ReportActionsUtils.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index a3c40dac88ac..981220360102 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -841,7 +841,7 @@ function shouldReportActionBeVisible(reportAction: OnyxEntry, key: return false; } - if (!shouldActionBeVisible(reportAction)) { + if (!isNotHiddenPreviewOrDeletedMoneyRequest(reportAction)) { return false; } @@ -993,7 +993,7 @@ function filterOutDeprecatedReportActions(reportActions: OnyxEntry Date: Mon, 28 Jul 2025 15:56:33 +0700 Subject: [PATCH 5/6] fix: lint --- src/libs/ReportActionsUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 981220360102..5cf099bdd2d6 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -993,6 +993,7 @@ function filterOutDeprecatedReportActions(reportActions: OnyxEntry Date: Tue, 29 Jul 2025 10:52:57 +0700 Subject: [PATCH 6/6] fix: rename function --- src/libs/ReportActionsUtils.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 5cf099bdd2d6..46a6a8aabb34 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -841,7 +841,7 @@ function shouldReportActionBeVisible(reportAction: OnyxEntry, key: return false; } - if (!isNotHiddenPreviewOrDeletedMoneyRequest(reportAction)) { + if (!isVisiblePreviewOrMoneyRequest(reportAction)) { return false; } @@ -993,8 +993,7 @@ function filterOutDeprecatedReportActions(reportActions: OnyxEntry