@@ -62,6 +62,7 @@ import {
6262 getExportIntegrationLastMessageText ,
6363 getIOUReportIDFromReportActionPreview ,
6464 getJoinRequestMessage ,
65+ getLastVisibleMessage ,
6566 getLeaveRoomMessage ,
6667 getMentionedAccountIDsFromAction ,
6768 getMessageOfOldDotReportAction ,
@@ -78,6 +79,7 @@ import {
7879 isActionableAddPaymentCard ,
7980 isActionableJoinRequest ,
8081 isActionOfType ,
82+ isAddCommentAction ,
8183 isClosedAction ,
8284 isCreatedTaskReportAction ,
8385 isDeletedAction ,
@@ -718,6 +720,7 @@ function hasHiddenDisplayNames(accountIDs: number[]) {
718720function getLastMessageTextForReport ( report : OnyxEntry < Report > , lastActorDetails : Partial < PersonalDetails > | null , policy ?: OnyxEntry < Policy > , isReportArchived = false ) : string {
719721 const reportID = report ?. reportID ;
720722 const lastReportAction = reportID ? lastVisibleReportActions [ reportID ] : undefined ;
723+ const lastVisibleMessage = getLastVisibleMessage ( report ?. reportID ) ;
721724
722725 // some types of actions are filtered out for lastReportAction, in some cases we need to check the actual last action
723726 const lastOriginalReportAction = reportID ? lastReportActions [ reportID ] : undefined ;
@@ -875,6 +878,11 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails
875878 }
876879 }
877880
881+ // If the last action is AddComment and no last message text was determined yet, use getLastVisibleMessage to get the preview text
882+ if ( reportID && ! lastMessageTextFromReport && isAddCommentAction ( lastReportAction ) ) {
883+ lastMessageTextFromReport = lastVisibleMessage ?. lastMessageText ;
884+ }
885+
878886 return lastMessageTextFromReport || ( report ?. lastMessageText ?? '' ) ;
879887}
880888
0 commit comments