From 64ccb57734d6492a088525bc1e83d8fa8373eb40 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Fri, 16 Feb 2024 17:59:45 -0500 Subject: [PATCH 01/10] add new isDeleted property --- src/libs/ReportActionsUtils.ts | 7 +++++-- src/types/onyx/ReportAction.ts | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index f9e2cd2220b3..68cf7fbf2239 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -94,9 +94,12 @@ function isCreatedAction(reportAction: OnyxEntry): boolean { } function isDeletedAction(reportAction: OnyxEntry): boolean { - // A deleted comment has either an empty array or an object with html field with empty string as value const message = reportAction?.message ?? []; - return message.length === 0 || message[0]?.html === ''; + + // A legacy deleted comment has either an empty array or an object with html field with empty string as value + const isLegacyDeletedComment = reportAction?.actionName === 'ADDCOMMENT' && (!message.length || !message[0]?.html); + + return message[0]?.isDeleted || isLegacyDeletedComment; } function isDeletedParentAction(reportAction: OnyxEntry): boolean { diff --git a/src/types/onyx/ReportAction.ts b/src/types/onyx/ReportAction.ts index 8f732a253cb5..0a9d7bc4c2f4 100644 --- a/src/types/onyx/ReportAction.ts +++ b/src/types/onyx/ReportAction.ts @@ -68,6 +68,8 @@ type Message = { /** resolution for actionable mention whisper */ resolution?: ValueOf | null; + + isDeleted?: boolean; }; type ImageMetadata = { From 1b685c9eefb92cd25ea3b2469fa42d973b061c2e Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Fri, 1 Mar 2024 16:39:03 -0500 Subject: [PATCH 02/10] use timestamp value for deleted --- src/libs/ReportActionsUtils.ts | 2 +- src/types/onyx/ReportAction.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 6dbcda1bfc30..0fc6af695ac4 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -101,7 +101,7 @@ function isDeletedAction(reportAction: OnyxEntry): boolean { diff --git a/src/types/onyx/ReportAction.ts b/src/types/onyx/ReportAction.ts index a45d49ea06dd..fa14f24daf71 100644 --- a/src/types/onyx/ReportAction.ts +++ b/src/types/onyx/ReportAction.ts @@ -71,7 +71,8 @@ type Message = { /** resolution for actionable mention whisper */ resolution?: ValueOf | null; - isDeleted?: boolean; + /** The time this report action was deleted */ + deleted?: string; }; type ImageMetadata = { From a197c1dd553e71a1034c17b1a7bf3137bd3b26da Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Fri, 1 Mar 2024 17:10:16 -0500 Subject: [PATCH 03/10] remove old comment --- src/libs/ReportActionsUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 0fc6af695ac4..4899f2181a5a 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -95,7 +95,6 @@ function isCreatedAction(reportAction: OnyxEntry): boolean { } function isDeletedAction(reportAction: OnyxEntry): boolean { - // A deleted comment has either an empty array or an object with html field with empty string as value const message = reportAction?.message ?? []; // A legacy deleted comment has either an empty array or an object with html field with empty string as value From 926701c1e653fed38fbcdd49f7020108ce53daad Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Tue, 5 Mar 2024 11:18:38 -0500 Subject: [PATCH 04/10] optimistically set deleted timestamp --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 5f9657755b02..440f8743c293 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -2982,7 +2982,7 @@ function deleteMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repor if (updatedReportPreviewAction?.message?.[0]) { updatedReportPreviewAction.message[0].text = messageText; - updatedReportPreviewAction.message[0].html = shouldDeleteIOUReport ? '' : messageText; + updatedReportPreviewAction.message[0].deleted = shouldDeleteIOUReport ? DateUtils.getDBTime() : ''; } if (updatedReportPreviewAction && reportPreviewAction?.childMoneyRequestCount && reportPreviewAction?.childMoneyRequestCount > 0) { From a3767180dfee9bf40fee255ce08259710da5fc50 Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Tue, 5 Mar 2024 11:19:08 -0500 Subject: [PATCH 05/10] stop deleting the preview action --- src/libs/actions/IOU.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 440f8743c293..b3598a81e9c2 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3087,12 +3087,10 @@ function deleteMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repor onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`, value: { - [reportPreviewAction?.reportActionID ?? '']: shouldDeleteIOUReport - ? null - : { - pendingAction: null, - errors: null, - }, + [reportPreviewAction?.reportActionID ?? '']: { + pendingAction: null, + errors: null, + }, }, }, ]; From d34836f499b6ccb87d2e1fcfd327d31158704f0c Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Wed, 6 Mar 2024 12:02:32 -0500 Subject: [PATCH 06/10] use const --- src/libs/ReportActionsUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 4899f2181a5a..e8d5c085fc5b 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -98,7 +98,7 @@ function isDeletedAction(reportAction: OnyxEntry Date: Wed, 6 Mar 2024 12:05:26 -0500 Subject: [PATCH 07/10] fix condition order --- src/libs/ReportActionsUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index e8d5c085fc5b..8744e178d8c1 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -100,7 +100,7 @@ function isDeletedAction(reportAction: OnyxEntry): boolean { From af1e735cc2bf31d610ed4fb6a3fc2af697055f5c Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Wed, 6 Mar 2024 12:25:34 -0500 Subject: [PATCH 08/10] fix optional chaining --- src/libs/ReportActionsUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index eb215a29bc78..22e1666e0988 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -100,7 +100,7 @@ function isDeletedAction(reportAction: OnyxEntry): boolean { From 68f5bbe5ebe88a196bdbfea263250d078d7b74db Mon Sep 17 00:00:00 2001 From: Andrew Rosiclair Date: Tue, 19 Mar 2024 15:36:34 -0400 Subject: [PATCH 09/10] remove ADDCOMMENT check --- src/libs/ReportActionsUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 22e1666e0988..47f2cabba46c 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -98,7 +98,7 @@ function isDeletedAction(reportAction: OnyxEntry Date: Wed, 20 Mar 2024 11:31:30 -0400 Subject: [PATCH 10/10] use strict equality check for html string --- src/libs/ReportActionsUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index adebdf807058..9dfa73b19e1a 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -106,7 +106,7 @@ function isDeletedAction(reportAction: OnyxEntry