diff --git a/src/components/ParentNavigationSubtitle.tsx b/src/components/ParentNavigationSubtitle.tsx index f793b4f8a60f..fc21d3d8b780 100644 --- a/src/components/ParentNavigationSubtitle.tsx +++ b/src/components/ParentNavigationSubtitle.tsx @@ -30,6 +30,11 @@ function ParentNavigationSubtitle({parentNavigationSubtitleData, parentReportAct const {isOffline} = useNetwork(); const {translate} = useLocalize(); + // We should not display the parent navigation subtitle if the user does not have access to the parent chat (the reportName is empty in this case) + if (!reportName) { + return; + } + return ( { diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 9c5e437a874e..7755c75544e5 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5965,6 +5965,13 @@ function isReportParticipant(accountID: number, report: OnyxEntry): bool return possibleAccountIDs.includes(accountID); } +/** + * Check to see if the current user has access to view the report. + */ +function canCurrentUserOpenReport(report: OnyxEntry): boolean { + return (isReportParticipant(currentUserAccountID ?? 0, report) || isPublicRoom(report)) && canAccessReport(report, allPolicies, allBetas); +} + function shouldUseFullTitleToDisplay(report: OnyxEntry): boolean { return ( isMoneyRequestReport(report) || isPolicyExpenseChat(report) || isChatRoom(report) || isChatThread(report) || isTaskReport(report) || isGroupChat(report) || isInvoiceReport(report) @@ -6493,6 +6500,7 @@ export { canBeAutoReimbursed, canCreateRequest, canCreateTaskInReport, + canCurrentUserOpenReport, canDeleteReportAction, canEditFieldOfMoneyRequest, canEditMoneyRequest, diff --git a/src/pages/home/report/RepliesDivider.tsx b/src/pages/home/report/RepliesDivider.tsx index deac38596c99..d6d5e1d3cfc8 100644 --- a/src/pages/home/report/RepliesDivider.tsx +++ b/src/pages/home/report/RepliesDivider.tsx @@ -7,6 +7,7 @@ import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import variables from '@styles/variables'; +import CONST from '@src/CONST'; type RepliesDividerProps = { /** Whether we should hide thread divider line */ @@ -19,14 +20,17 @@ function RepliesDivider({shouldHideThreadDividerLine}: RepliesDividerProps) { const {translate} = useLocalize(); return ( - + - {translate('threads.replies')} + {translate('threads.replies')} {!shouldHideThreadDividerLine && } ); diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 917031336fc8..7740f4bcfd93 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -955,7 +955,12 @@ function ReportActionItem({ checkIfContextMenuActive={toggleContextMenuFromActiveReportAction} setIsEmojiPickerActive={setIsEmojiPickerActive} /> - + ReportActions.clearAllRelatedReportActionErrors(report.reportID, action)} // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing diff --git a/src/pages/home/report/ReportActionItemParentAction.tsx b/src/pages/home/report/ReportActionItemParentAction.tsx index 5de85eb5f43f..a32900fdd502 100644 --- a/src/pages/home/report/ReportActionItemParentAction.tsx +++ b/src/pages/home/report/ReportActionItemParentAction.tsx @@ -112,17 +112,24 @@ function ReportActionItemParentAction({ errorRowStyles={[styles.ml10, styles.mr2]} onClose={() => Report.navigateToConciergeChatAndDeleteReport(ancestor.report.reportID)} > - + { - const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID ?? ''); - // Pop the thread report screen before navigating to the chat report. - Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '')); - if (isVisibleAction && !isOffline) { - // Pop the chat report screen before navigating to the linked report action. - Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', ancestor.reportAction.reportActionID)); - } - }} + onPress={ + ReportUtils.canCurrentUserOpenReport(ReportUtils.getReport(ancestor?.report?.parentReportID)) + ? () => { + const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID ?? ''); + // Pop the thread report screen before navigating to the chat report. + Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '')); + if (isVisibleAction && !isOffline) { + // Pop the chat report screen before navigating to the linked report action. + Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', ancestor.reportAction.reportActionID)); + } + } + : undefined + } parentReportAction={parentReportAction} report={ancestor.report} reportActions={reportActions} diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index 7d95d3555502..5cd50a27ef05 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -555,7 +555,7 @@ function ReportActionsList({ mostRecentIOUReportActionID={mostRecentIOUReportActionID} shouldHideThreadDividerLine={shouldHideThreadDividerLine} shouldDisplayNewMarker={shouldDisplayNewMarker(reportAction, index)} - shouldDisplayReplyDivider={sortedReportActions.length > 1} + shouldDisplayReplyDivider={sortedVisibleReportActions.length > 1} isFirstVisibleReportAction={firstVisibleReportActionID === reportAction.reportActionID} shouldUseThreadDividerLine={shouldUseThreadDividerLine} /> @@ -564,7 +564,6 @@ function ReportActionsList({ report, linkedReportActionID, sortedVisibleReportActions, - sortedReportActions.length, mostRecentIOUReportActionID, shouldHideThreadDividerLine, shouldDisplayNewMarker, diff --git a/src/pages/home/report/ThreadDivider.tsx b/src/pages/home/report/ThreadDivider.tsx index edbe2c665752..9f79dfdedba8 100644 --- a/src/pages/home/report/ThreadDivider.tsx +++ b/src/pages/home/report/ThreadDivider.tsx @@ -18,38 +18,56 @@ import ROUTES from '@src/ROUTES'; type ThreadDividerProps = { /** Thread ancestor */ ancestor: Ancestor; + + /** Whether the link is disabled */ + isLinkDisabled?: boolean; }; -function ThreadDivider({ancestor}: ThreadDividerProps) { +function ThreadDivider({ancestor, isLinkDisabled = false}: ThreadDividerProps) { const styles = useThemeStyles(); const theme = useTheme(); const {translate} = useLocalize(); const {isOffline} = useNetwork(); return ( - - { - const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID ?? ''); - // Pop the thread report screen before navigating to the chat report. - Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '')); - if (isVisibleAction && !isOffline) { - // Pop the chat report screen before navigating to the linked report action. - Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', ancestor.reportAction.reportActionID)); - } - }} - accessibilityLabel={translate('threads.thread')} - role={CONST.ROLE.BUTTON} - style={[styles.flexRow, styles.alignItemsCenter, styles.gap1]} - > - - {translate('threads.thread')} - + + {isLinkDisabled ? ( + <> + + {translate('threads.thread')} + + ) : ( + { + const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(ancestor.reportAction, ancestor.reportAction.reportActionID ?? ''); + // Pop the thread report screen before navigating to the chat report. + Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '')); + if (isVisibleAction && !isOffline) { + // Pop the chat report screen before navigating to the linked report action. + Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(ancestor.report.parentReportID ?? '', ancestor.reportAction.reportActionID)); + } + }} + accessibilityLabel={translate('threads.thread')} + role={CONST.ROLE.BUTTON} + style={[styles.flexRow, styles.alignItemsCenter, styles.gap1]} + > + + {translate('threads.thread')} + + )} {!ancestor.shouldDisplayNewMarker && } );