diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 004087c22308..5e41e33b18a4 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -37,6 +37,7 @@ import ReportScreenContext from './ReportScreenContext'; import TaskHeaderActionButton from '../../components/TaskHeaderActionButton'; import DragAndDropProvider from '../../components/DragAndDrop/Provider'; import usePrevious from '../../hooks/usePrevious'; +import CONST from '../../CONST'; import withCurrentReportID, {withCurrentReportIDPropTypes, withCurrentReportIDDefaultProps} from '../../components/withCurrentReportID'; const propTypes = { @@ -107,6 +108,15 @@ const defaultProps = { ...withCurrentReportIDDefaultProps, }; +/** + * + * Function to check weather the report available in props is default + * + * @param {Object} report + * @returns {Boolean} + */ +const checkDefaultReport = (report) => report === defaultProps.report; + /** * Get the currently viewed report ID as number * @@ -151,6 +161,8 @@ function ReportScreen({ // There are no reportActions at all to display and we are still in the process of loading the next set of actions. const isLoadingInitialReportActions = _.isEmpty(reportActions) && report.isLoadingReportActions; + const isOptimisticDelete = lodashGet(report, 'statusNum') === CONST.REPORT.STATUS.CLOSED; + const shouldHideReport = !ReportUtils.canAccessReport(report, policies, betas); const isLoading = !reportID || !isSidebarLoaded || _.isEmpty(personalDetails) || firstRenderRef.current; @@ -163,6 +175,8 @@ function ReportScreen({ const isTopMostReportId = currentReportID === getReportID(route); + const isDefaultReport = checkDefaultReport(report); + let headerView = ( (!_.isEmpty(report) && !isDefaultReport && !report.reportID && !isOptimisticDelete && !report.isLoadingReportActions && !isLoading) || shouldHideReport, + [report, isLoading, shouldHideReport, isDefaultReport, isOptimisticDelete], + ); + return (