diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index d5e68e78d927..9ff46ad15c84 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -328,6 +328,18 @@ type PureReportActionItemProps = { const emptyHTML = ; const isEmptyHTML = ({props: {html}}: T): boolean => typeof html === 'string' && html.length === 0; +const useNewTableReportViewActionRenderConditionals = ({childMoneyRequestCount, childVisibleActionCount, pendingAction, actionName}: OnyxTypes.ReportAction) => { + const previousChildMoneyRequestCount = usePrevious(childMoneyRequestCount); + + return !( + actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && + pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE && + childMoneyRequestCount === 0 && + (childVisibleActionCount ?? 0) > 0 && + (previousChildMoneyRequestCount ?? 0) > 0 + ); +}; + /** * This is a pure version of ReportActionItem, used in ReportActionList and Search result chat list items. * Since the search result has a separate Onyx key under the 'snapshot_' prefix, we should not connect this component with Onyx. @@ -390,7 +402,7 @@ function PureReportActionItem({ const [isEmojiPickerActive, setIsEmojiPickerActive] = useState(); const [isPaymentMethodPopoverActive, setIsPaymentMethodPopoverActive] = useState(); const {canUseTableReportView} = usePermissions(); - + const shouldRenderViewBasedOnAction = useNewTableReportViewActionRenderConditionals(action); const [isHidden, setIsHidden] = useState(false); const [moderationDecision, setModerationDecision] = useState(CONST.MODERATION.MODERATOR_DECISION_APPROVED); const reactionListRef = useContext(ReactionListContext); @@ -1131,8 +1143,8 @@ function PureReportActionItem({ const renderReportActionItem = (hovered: boolean, isWhisper: boolean, hasErrors: boolean): React.JSX.Element => { const content = renderItemContent(hovered || isContextMenuActive || isEmojiPickerActive, isWhisper, hasErrors); - if (canUseTableReportView && isEmptyHTML(content)) { - return content; + if (canUseTableReportView && (isEmptyHTML(content) || (!shouldRenderViewBasedOnAction && !isClosedExpenseReportWithNoExpenses))) { + return emptyHTML; } if (draftMessage !== undefined) {