Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,12 @@ function isCreatedAction(reportAction: OnyxEntry<ReportAction>): boolean {
}

function isDeletedAction(reportAction: OnyxEntry<ReportAction | OptimisticIOUReportAction>): 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 = message.length === 0 || message[0]?.html === '';

return isLegacyDeletedComment || !!message[0]?.deleted;
}

function isDeletedParentAction(reportAction: OnyxEntry<ReportAction>): boolean {
Expand Down
12 changes: 5 additions & 7 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3015,7 +3015,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) {
Expand Down Expand Up @@ -3120,12 +3120,10 @@ function deleteMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repor
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`,
value: {
[reportPreviewAction?.reportActionID ?? '']: shouldDeleteIOUReport
Comment thread
arosiclair marked this conversation as resolved.
? null
: {
pendingAction: null,
errors: null,
},
[reportPreviewAction?.reportActionID ?? '']: {
pendingAction: null,
errors: null,
},
},
},
];
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/ReportAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ type Message = {

/** resolution for actionable mention whisper */
resolution?: ValueOf<typeof CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION> | null;

/** The time this report action was deleted */
deleted?: string;
};

type ImageMetadata = {
Expand Down