Skip to content

Commit

Permalink
Merge pull request #25554 from dukenv0307/fix/24648
Browse files Browse the repository at this point in the history
Fix: Two line markers appear for a second
  • Loading branch information
MariaHCD authored Oct 23, 2023
2 parents 0811311 + 013f3c4 commit 0fa68e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,19 @@ function getLastClosedReportAction(reportActions: ReportActions | null): OnyxEnt
return lodashFindLast(sortedReportActions, (action) => action.actionName === CONST.REPORT.ACTIONS.TYPE.CLOSED) ?? null;
}

/**
* The first visible action is the second last action in sortedReportActions which satisfy following conditions:
* 1. That is not pending deletion as pending deletion actions are kept in sortedReportActions in memory.
* 2. That has at least one visible child action.
* 3. While offline all actions in `sortedReportActions` are visible.
* 4. We will get the second last action from filtered actions because the last
* action is always the created action
*/
function getFirstVisibleReportActionID(sortedReportActions: ReportAction[], isOffline: boolean): string {
const sortedFilterReportActions = sortedReportActions.filter((action) => !isDeletedAction(action) || (action?.childVisibleActionCount ?? 0) > 0 || isOffline);
return sortedFilterReportActions.length > 1 ? sortedFilterReportActions[sortedFilterReportActions.length - 2].reportActionID : '';
}

/**
* @returns The latest report action in the `onyxData` or `null` if one couldn't be found
*/
Expand Down Expand Up @@ -643,4 +656,5 @@ export {
isReimbursementQueuedAction,
shouldReportActionBeVisible,
shouldReportActionBeVisibleAsLastAction,
getFirstVisibleReportActionID,
};
4 changes: 2 additions & 2 deletions src/pages/home/report/ReportActionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ function ReportActionsList({
* This is so that it will not be conflicting with header's separator line.
*/
const shouldHideThreadDividerLine = useMemo(
() => sortedReportActions.length > 1 && sortedReportActions[sortedReportActions.length - 2].reportActionID === currentUnreadMarker,
[sortedReportActions, currentUnreadMarker],
() => ReportActionsUtils.getFirstVisibleReportActionID(sortedReportActions, isOffline) === currentUnreadMarker,
[sortedReportActions, isOffline, currentUnreadMarker],
);

/**
Expand Down

0 comments on commit 0fa68e6

Please sign in to comment.