diff --git a/src/components/LHNOptionsList/OptionRowLHN.js b/src/components/LHNOptionsList/OptionRowLHN.js index ba035c8b3baf..c645a17b07d4 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.js +++ b/src/components/LHNOptionsList/OptionRowLHN.js @@ -257,7 +257,7 @@ function OptionRowLHN(props) { numberOfLines={1} accessibilityLabel={translate('accessibilityHints.lastChatMessagePreview')} > - {optionItem.isLastMessageDeletedParentAction ? translate('parentReportAction.deletedMessage') : optionItem.alternateText} + {optionItem.alternateText} ) : null} diff --git a/src/libs/SidebarUtils.js b/src/libs/SidebarUtils.js index caa8fb384e56..bd3d730edc0c 100644 --- a/src/libs/SidebarUtils.js +++ b/src/libs/SidebarUtils.js @@ -267,7 +267,6 @@ function getOptionData(report, reportActions, personalDetails, preferredLocale, isMoneyRequestReport: false, isExpenseRequest: false, isWaitingOnBankAccount: false, - isLastMessageDeletedParentAction: false, isAllowedToComment: true, }; @@ -429,7 +428,6 @@ function getOptionData(report, reportActions, personalDetails, preferredLocale, result.icons = ReportUtils.getIcons(report, personalDetails, UserUtils.getAvatar(personalDetail.avatar, personalDetail.accountID), '', -1, policy); result.searchText = OptionsListUtils.getSearchText(report, reportName, participantPersonalDetailList, result.isChatRoom || result.isPolicyExpenseChat, result.isThread); result.displayNamesWithTooltips = displayNamesWithTooltips; - result.isLastMessageDeletedParentAction = report.isLastMessageDeletedParentAction; if (status) { result.status = status; diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index dc881252e4d8..be9e93c4c867 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -326,7 +326,6 @@ function addActions(reportID, text = '', file) { lastMessageHtml: lastCommentText, lastActorAccountID: currentUserAccountID, lastReadTime: currentTime, - isLastMessageDeletedParentAction: null, }; // Optimistically add the new actions to the store before waiting to save them to the server @@ -1047,25 +1046,17 @@ function deleteReportComment(reportID, reportAction) { lastMessageText: '', lastVisibleActionCreated: '', }; - if (reportAction.childVisibleActionCount === 0) { + const {lastMessageText = '', lastMessageTranslationKey = ''} = ReportUtils.getLastVisibleMessage(originalReportID, optimisticReportActions); + if (lastMessageText || lastMessageTranslationKey) { + const lastVisibleAction = ReportActionsUtils.getLastVisibleAction(originalReportID, optimisticReportActions); + const lastVisibleActionCreated = lodashGet(lastVisibleAction, 'created'); + const lastActorAccountID = lodashGet(lastVisibleAction, 'actorAccountID'); optimisticReport = { - lastMessageTranslationKey: '', - lastMessageText: '', - isLastMessageDeletedParentAction: true, + lastMessageTranslationKey, + lastMessageText, + lastVisibleActionCreated, + lastActorAccountID, }; - } else { - const {lastMessageText = '', lastMessageTranslationKey = ''} = ReportUtils.getLastVisibleMessage(originalReportID, optimisticReportActions); - if (lastMessageText || lastMessageTranslationKey) { - const lastVisibleAction = ReportActionsUtils.getLastVisibleAction(originalReportID, optimisticReportActions); - const lastVisibleActionCreated = lodashGet(lastVisibleAction, 'created'); - const lastActorAccountID = lodashGet(lastVisibleAction, 'actorAccountID'); - optimisticReport = { - lastMessageTranslationKey, - lastMessageText, - lastVisibleActionCreated, - lastActorAccountID, - }; - } } // If the API call fails we must show the original message again, so we revert the message content back to how it was