Skip to content

Commit

Permalink
Merge pull request #38968 from Expensify/Rory-IncorrectReportActionCh…
Browse files Browse the repository at this point in the history
…ainForOptimisticDelete

Make getContinuousReportActionChain consider any optimistic action

(cherry picked from commit 525b1ba)
  • Loading branch information
roryabraham authored and OSBotify committed Mar 26, 2024
1 parent 4e3b477 commit 9f2a7e3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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--;
Expand Down

0 comments on commit 9f2a7e3

Please sign in to comment.