Skip to content

Commit

Permalink
fix delete comment issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dukenv0307 committed Mar 1, 2024
1 parent c2613a7 commit 1286f6d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ function getLastVisibleMessage(reportID: string, actionsToMerge: OnyxCollection<
}
return {
lastMessageText: messageText,
lastMessageHtml: message?.html,
};
}

Expand Down
3 changes: 1 addition & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1805,15 +1805,14 @@ function buildOptimisticCancelPaymentReportAction(expenseReportID: string, amoun
function getLastVisibleMessage(reportID: string | undefined, actionsToMerge: ReportActions = {}): LastVisibleMessage {
const report = getReport(reportID);
const lastVisibleAction = ReportActionsUtils.getLastVisibleAction(reportID ?? '', actionsToMerge);

// For Chat Report with deleted parent actions, let us fetch the correct message
if (ReportActionsUtils.isDeletedParentAction(lastVisibleAction) && !isEmptyObject(report) && isChatReport(report)) {
const lastMessageText = getDeletedParentActionMessageForChatReport(lastVisibleAction);
return {
lastMessageText,
};
}

// Fetch the last visible message for report represented by reportID and based on actions to merge.
return ReportActionsUtils.getLastVisibleMessage(reportID ?? '', actionsToMerge);
}
Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ function deleteReportComment(reportID: string, reportAction: ReportAction) {
lastMessageText: '',
lastVisibleActionCreated: '',
};
const {lastMessageText = '', lastMessageTranslationKey = ''} = ReportUtils.getLastVisibleMessage(originalReportID, optimisticReportActions as ReportActions);
const {lastMessageText = '', lastMessageTranslationKey = '', lastMessageHtml = ''} = ReportUtils.getLastVisibleMessage(originalReportID, optimisticReportActions as ReportActions);
if (lastMessageText || lastMessageTranslationKey) {
const lastVisibleAction = ReportActionsUtils.getLastVisibleAction(originalReportID, optimisticReportActions as ReportActions);
const lastVisibleActionCreated = lastVisibleAction?.created;
Expand All @@ -1179,6 +1179,7 @@ function deleteReportComment(reportID: string, reportAction: ReportAction) {
lastMessageText,
lastVisibleActionCreated,
lastActorAccountID,
lastMessageHtml
};
}

Expand Down

0 comments on commit 1286f6d

Please sign in to comment.