Skip to content

Commit

Permalink
Merge pull request #36747 from Expensify/arosiclair-deleted-report-ac…
Browse files Browse the repository at this point in the history
…tions

Use new isDeleted property for deleted actions
  • Loading branch information
arosiclair authored Mar 21, 2024
2 parents 553529d + 82c9fc6 commit fb344de
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,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 @@ -3626,7 +3626,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 @@ -3731,12 +3731,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,
},
},
},
];
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

0 comments on commit fb344de

Please sign in to comment.