diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 764699947a97..2b532b59575f 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2585,6 +2585,14 @@ function getPolicy(policyID) { } /* + * @param {Object|null} report + * @returns {Boolean} + */ +function shouldDisableSettings(report) { + return !isPolicyExpenseChat(report) && !isChatRoom(report) && !isChatThread(report); +} + +/** * @param {Object|null} report * @param {Object|null} policy - the workspace the report is on, null if the user isn't a member of the workspace * @returns {Boolean} @@ -2712,5 +2720,6 @@ export { canAccessReport, getReportOfflinePendingActionAndErrors, getPolicy, + shouldDisableSettings, shouldDisableRename, }; diff --git a/src/pages/ReportDetailsPage.js b/src/pages/ReportDetailsPage.js index e65307c6322c..b8daf12c2ca7 100644 --- a/src/pages/ReportDetailsPage.js +++ b/src/pages/ReportDetailsPage.js @@ -60,8 +60,8 @@ const defaultProps = { function ReportDetailsPage(props) { const policy = useMemo(() => props.policies[`${ONYXKEYS.COLLECTION.POLICY}${props.report.policyID}`], [props.policies, props.report.policyID]); const isPolicyAdmin = useMemo(() => PolicyUtils.isPolicyAdmin(policy), [policy]); - const isPolicyExpenseChat = useMemo(() => ReportUtils.isPolicyExpenseChat(props.report), [props.report]); - const isChatRoom = useMemo(() => ReportUtils.isChatRoom(props.report), [props.report]); + const shouldDisableSettings = useMemo(() => ReportUtils.shouldDisableSettings(props.report), [props.report]); + const shouldUseFullTitle = shouldDisableSettings; const isThread = useMemo(() => ReportUtils.isChatThread(props.report), [props.report]); const isUserCreatedPolicyRoom = useMemo(() => ReportUtils.isUserCreatedPolicyRoom(props.report), [props.report]); const isArchivedRoom = useMemo(() => ReportUtils.isArchivedRoom(props.report), [props.report]); @@ -99,7 +99,7 @@ function ReportDetailsPage(props) { }); } - if (isPolicyExpenseChat || isChatRoom || isThread) { + if (!shouldDisableSettings) { items.push({ key: CONST.REPORT_DETAILS_MENU_ITEM.SETTINGS, translationKey: 'common.settings', @@ -122,7 +122,7 @@ function ReportDetailsPage(props) { } return items; - }, [props.report.reportID, participants, isArchivedRoom, isPolicyExpenseChat, isChatRoom, isThread, isUserCreatedPolicyRoom, canLeaveRoom]); + }, [props.report.reportID, participants, isArchivedRoom, shouldDisableSettings, isThread, isUserCreatedPolicyRoom, canLeaveRoom]); const displayNamesWithTooltips = useMemo(() => { const hasMultipleParticipants = participants.length > 1; @@ -155,7 +155,7 @@ function ReportDetailsPage(props) { tooltipEnabled numberOfLines={1} textStyles={[styles.textHeadline, styles.textAlignCenter, styles.pre]} - shouldUseFullTitle={isChatRoom || isPolicyExpenseChat || isThread} + shouldUseFullTitle={shouldUseFullTitle} /> {isPolicyAdmin ? ( diff --git a/src/pages/settings/Report/NotificationPreferencePage.js b/src/pages/settings/Report/NotificationPreferencePage.js index 915a32180ad8..a32245b10518 100644 --- a/src/pages/settings/Report/NotificationPreferencePage.js +++ b/src/pages/settings/Report/NotificationPreferencePage.js @@ -8,9 +8,11 @@ import OptionsList from '../../../components/OptionsList'; import Navigation from '../../../libs/Navigation/Navigation'; import compose from '../../../libs/compose'; import withReportOrNotFound from '../../home/report/withReportOrNotFound'; +import FullPageNotFoundView from '../../../components/BlockingViews/FullPageNotFoundView'; import reportPropTypes from '../../reportPropTypes'; import ROUTES from '../../../ROUTES'; import * as Report from '../../../libs/actions/Report'; +import * as ReportUtils from '../../../libs/ReportUtils'; import * as Expensicons from '../../../components/Icon/Expensicons'; import themeColors from '../../../styles/themes/default'; @@ -23,6 +25,7 @@ const propTypes = { const greenCheckmark = {src: Expensicons.Checkmark, color: themeColors.success}; function NotificationPreferencePage(props) { + const shouldDisableNotificationPreferences = ReportUtils.shouldDisableSettings(props.report); const notificationPreferenceOptions = _.map(props.translate('notificationPreferencesPage.notificationPreferences'), (preference, key) => ({ value: key, text: preference, @@ -37,23 +40,25 @@ function NotificationPreferencePage(props) { return ( - Navigation.goBack(ROUTES.getReportSettingsRoute(props.report.reportID))} - /> - Report.updateNotificationPreferenceAndNavigate(props.report.reportID, props.report.notificationPreference, option.value)} - hideSectionHeaders - optionHoveredStyle={{ - ...styles.hoveredComponentBG, - ...styles.mhn5, - ...styles.ph5, - }} - shouldHaveOptionSeparator - shouldDisableRowInnerPadding - contentContainerStyles={[styles.ph5]} - /> + + Navigation.goBack(ROUTES.getReportSettingsRoute(props.report.reportID))} + /> + Report.updateNotificationPreferenceAndNavigate(props.report.reportID, props.report.notificationPreference, option.value)} + hideSectionHeaders + optionHoveredStyle={{ + ...styles.hoveredComponentBG, + ...styles.mhn5, + ...styles.ph5, + }} + shouldHaveOptionSeparator + shouldDisableRowInnerPadding + contentContainerStyles={[styles.ph5]} + /> + ); } diff --git a/src/pages/settings/Report/ReportSettingsPage.js b/src/pages/settings/Report/ReportSettingsPage.js index c1eaaeed5e26..7af58818b4db 100644 --- a/src/pages/settings/Report/ReportSettingsPage.js +++ b/src/pages/settings/Report/ReportSettingsPage.js @@ -66,6 +66,7 @@ class ReportSettingsPage extends Component { } render() { + const shouldDisableSettings = ReportUtils.shouldDisableSettings(this.props.report); const shouldShowRoomName = !ReportUtils.isPolicyExpenseChat(this.props.report) && !ReportUtils.isChatThread(this.props.report); const linkedWorkspace = _.find(this.props.policies, (policy) => policy && policy.id === this.props.report.policyID); const shouldDisableRename = ReportUtils.shouldDisableRename(this.props.report, linkedWorkspace) || ReportUtils.isChatThread(this.props.report); @@ -80,7 +81,7 @@ class ReportSettingsPage extends Component { return ( - + Navigation.goBack(ROUTES.getReportDetailsRoute(this.props.report.reportID))}