diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 64bac4f46b5a..11f870b891b6 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -263,9 +263,14 @@ function getContinuousReportActionChain(sortedReportActions: ReportAction[], id? let index; if (id) { - index = sortedReportActions.findIndex((obj) => obj.reportActionID === id); + index = sortedReportActions.findIndex((reportAction) => reportAction.reportActionID === id); } else { - index = sortedReportActions.findIndex((obj) => obj.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD); + index = sortedReportActions.findIndex( + (reportAction) => + reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && + reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && + !reportAction.isOptimisticAction, + ); } if (index === -1) { @@ -299,6 +304,9 @@ function getContinuousReportActionChain(sortedReportActions: ReportAction[], id? while ( (startIndex > 0 && sortedReportActions[startIndex].reportActionID === sortedReportActions[startIndex - 1].previousReportActionID) || sortedReportActions[startIndex - 1]?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD || + sortedReportActions[startIndex - 1]?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + sortedReportActions[startIndex - 1]?.isOptimisticAction || sortedReportActions[startIndex - 1]?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOMCHANGELOG.INVITE_TO_ROOM ) { startIndex--;