diff --git a/src/libs/Notification/LocalNotification/BrowserNotifications.js b/src/libs/Notification/LocalNotification/BrowserNotifications.js index 520f0de17bea..3199e4c6388d 100644 --- a/src/libs/Notification/LocalNotification/BrowserNotifications.js +++ b/src/libs/Notification/LocalNotification/BrowserNotifications.js @@ -111,7 +111,7 @@ export default { const plainTextMessage = (_.find(message, (f) => f.type === 'COMMENT') || {}).text; if (isChatRoom) { - const roomName = _.get(report, 'reportName', ''); + const roomName = ReportUtils.getReportName(report); title = roomName; body = `${plainTextPerson}: ${plainTextMessage}`; } else { diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 591656b5c06a..ce919efddfea 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1900,15 +1900,11 @@ function getParentNavigationSubtitle(report) { function navigateToDetailsPage(report) { const participantAccountIDs = lodashGet(report, 'participantAccountIDs', []); - if (isChatRoom(report) || isPolicyExpenseChat(report) || isChatThread(report) || isTaskReport(report) || isMoneyRequestReport(report)) { - Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID)); - return; - } - if (participantAccountIDs.length === 1) { + if (isDM(report) && participantAccountIDs.length === 1) { Navigation.navigate(ROUTES.PROFILE.getRoute(participantAccountIDs[0])); return; } - Navigation.navigate(ROUTES.REPORT_PARTICIPANTS.getRoute(report.reportID)); + Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report.reportID)); } /** @@ -3589,14 +3585,6 @@ function getWorkspaceChats(policyID, accountIDs) { return _.filter(allReports, (report) => isPolicyExpenseChat(report) && lodashGet(report, 'policyID', '') === policyID && _.contains(accountIDs, lodashGet(report, 'ownerAccountID', ''))); } -/* - * @param {Object|null} report - * @returns {Boolean} - */ -function shouldDisableSettings(report) { - return !isMoneyRequestReport(report) && !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 @@ -3955,7 +3943,6 @@ export { getPolicy, getPolicyExpenseChatReportIDByOwner, getWorkspaceChats, - shouldDisableSettings, shouldDisableRename, hasSingleParticipant, getReportRecipientAccountIDs, diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js index 7e93f4d99be2..b51671341e40 100755 --- a/src/pages/ProfilePage.js +++ b/src/pages/ProfilePage.js @@ -37,6 +37,7 @@ import variables from '../styles/variables'; import * as ValidationUtils from '../libs/ValidationUtils'; import Permissions from '../libs/Permissions'; import ROUTES from '../ROUTES'; +import MenuItemWithTopDescription from '../components/MenuItemWithTopDescription'; const matchType = PropTypes.shape({ params: PropTypes.shape({ @@ -135,7 +136,7 @@ function ProfilePage(props) { const navigateBackTo = lodashGet(props.route, 'params.backTo', ROUTES.HOME); - const chatReportWithCurrentUser = !isCurrentUser && !Session.isAnonymousUser() ? ReportUtils.getChatByParticipants([accountID]) : 0; + const notificationPreference = !_.isEmpty(props.report) ? props.translate(`notificationPreferencesPage.notificationPreferences.${props.report.notificationPreference}`) : ''; // eslint-disable-next-line rulesdir/prefer-early-return useEffect(() => { @@ -231,6 +232,15 @@ function ProfilePage(props) { ) : null} {shouldShowLocalTime && } + {!_.isEmpty(props.report) && notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN && ( + Navigation.navigate(ROUTES.REPORT_SETTINGS_NOTIFICATION_PREFERENCES.getRoute(props.report.reportID))} + wrapperStyle={[styles.mtn6, styles.mb5]} + /> + )} {!isCurrentUser && !Session.isAnonymousUser() && ( )} - {!_.isEmpty(chatReportWithCurrentUser) && ( + {!_.isEmpty(props.report) && ( Navigation.navigate(ROUTES.PRIVATE_NOTES_LIST.getRoute(chatReportWithCurrentUser.reportID))} + onPress={() => Navigation.navigate(ROUTES.PRIVATE_NOTES_LIST.getRoute(props.report.reportID))} wrapperStyle={styles.breakAll} shouldShowRightIcon - brickRoadIndicator={Report.hasErrorInPrivateNotes(chatReportWithCurrentUser) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''} + brickRoadIndicator={Report.hasErrorInPrivateNotes(props.report) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''} /> )} @@ -289,5 +299,20 @@ export default compose( betas: { key: ONYXKEYS.BETAS, }, + session: { + key: ONYXKEYS.SESSION, + }, + }), + // eslint-disable-next-line rulesdir/no-multiple-onyx-in-file + withOnyx({ + report: { + key: ({route, session}) => { + const accountID = Number(lodashGet(route.params, 'accountID', 0)); + if (Number(session.accountID) === accountID || Session.isAnonymousUser()) { + return null; + } + return `${ONYXKEYS.COLLECTION.REPORT}${lodashGet(ReportUtils.getChatByParticipants([accountID]), 'reportID', '')}`; + }, + }, }), )(ProfilePage); diff --git a/src/pages/ReportDetailsPage.js b/src/pages/ReportDetailsPage.js index e4ce09fc7e1a..42a535844c72 100644 --- a/src/pages/ReportDetailsPage.js +++ b/src/pages/ReportDetailsPage.js @@ -61,8 +61,7 @@ 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 shouldDisableSettings = useMemo(() => ReportUtils.shouldDisableSettings(props.report), [props.report]); - const shouldUseFullTitle = !shouldDisableSettings || ReportUtils.isTaskReport(props.report); + const shouldUseFullTitle = ReportUtils.isTaskReport(props.report); const isChatRoom = useMemo(() => ReportUtils.isChatRoom(props.report), [props.report]); const isThread = useMemo(() => ReportUtils.isChatThread(props.report), [props.report]); const isUserCreatedPolicyRoom = useMemo(() => ReportUtils.isUserCreatedPolicyRoom(props.report), [props.report]); @@ -75,16 +74,20 @@ function ReportDetailsPage(props) { const canLeaveRoom = useMemo(() => ReportUtils.canLeaveRoom(props.report, !_.isEmpty(policy)), [policy, props.report]); const participants = useMemo(() => ReportUtils.getParticipantsIDs(props.report), [props.report]); + const isGroupDMChat = useMemo(() => ReportUtils.isDM(props.report) && participants.length > 1, [props.report, participants.length]); + const menuItems = useMemo(() => { - const items = [ - { + const items = []; + + if (!isGroupDMChat) { + items.push({ key: CONST.REPORT_DETAILS_MENU_ITEM.SHARE_CODE, translationKey: 'common.shareCode', icon: Expensicons.QrCode, isAnonymousAction: true, action: () => Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS_SHARE_CODE.getRoute(props.report.reportID)), - }, - ]; + }); + } if (isArchivedRoom) { return items; @@ -103,17 +106,15 @@ function ReportDetailsPage(props) { }); } - if (!shouldDisableSettings) { - items.push({ - key: CONST.REPORT_DETAILS_MENU_ITEM.SETTINGS, - translationKey: 'common.settings', - icon: Expensicons.Gear, - isAnonymousAction: false, - action: () => { - Navigation.navigate(ROUTES.REPORT_SETTINGS.getRoute(props.report.reportID)); - }, - }); - } + items.push({ + key: CONST.REPORT_DETAILS_MENU_ITEM.SETTINGS, + translationKey: 'common.settings', + icon: Expensicons.Gear, + isAnonymousAction: false, + action: () => { + Navigation.navigate(ROUTES.REPORT_SETTINGS.getRoute(props.report.reportID)); + }, + }); // Prevent displaying private notes option for threads and task reports if (!isThread && !isMoneyRequestReport && !ReportUtils.isTaskReport(props.report)) { @@ -138,7 +139,7 @@ function ReportDetailsPage(props) { } return items; - }, [isArchivedRoom, participants.length, shouldDisableSettings, isThread, isMoneyRequestReport, props.report, isUserCreatedPolicyRoom, canLeaveRoom]); + }, [isArchivedRoom, participants.length, isThread, isMoneyRequestReport, props.report, isUserCreatedPolicyRoom, canLeaveRoom, isGroupDMChat]); const displayNamesWithTooltips = useMemo(() => { const hasMultipleParticipants = participants.length > 1; diff --git a/src/pages/settings/Report/NotificationPreferencePage.js b/src/pages/settings/Report/NotificationPreferencePage.js index a69b227470d6..7dc9ff7773de 100644 --- a/src/pages/settings/Report/NotificationPreferencePage.js +++ b/src/pages/settings/Report/NotificationPreferencePage.js @@ -26,7 +26,7 @@ const propTypes = { const greenCheckmark = {src: Expensicons.Checkmark, color: themeColors.success}; function NotificationPreferencePage(props) { - const shouldDisableNotificationPreferences = ReportUtils.shouldDisableSettings(props.report) || ReportUtils.isArchivedRoom(props.report); + const shouldDisableNotificationPreferences = ReportUtils.isArchivedRoom(props.report); const notificationPreferenceOptions = _.map( _.filter(_.values(CONST.REPORT.NOTIFICATION_PREFERENCE), (pref) => pref !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN), (preference) => ({ diff --git a/src/pages/settings/Report/ReportSettingsPage.js b/src/pages/settings/Report/ReportSettingsPage.js index 9f4f4d048354..5612096207bb 100644 --- a/src/pages/settings/Report/ReportSettingsPage.js +++ b/src/pages/settings/Report/ReportSettingsPage.js @@ -64,7 +64,7 @@ function ReportSettingsPage(props) { const shouldDisableWelcomeMessage = isMoneyRequestReport || ReportUtils.isArchivedRoom(report) || !ReportUtils.isChatRoom(report) || _.isEmpty(linkedWorkspace) || linkedWorkspace.role !== CONST.POLICY.ROLE.ADMIN; - const shouldDisableSettings = _.isEmpty(report) || ReportUtils.shouldDisableSettings(report) || ReportUtils.isArchivedRoom(report); + const shouldDisableSettings = _.isEmpty(report) || ReportUtils.isArchivedRoom(report); const shouldShowRoomName = !ReportUtils.isPolicyExpenseChat(report) && !ReportUtils.isChatThread(report); const notificationPreference = report.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN diff --git a/src/styles/utilities/spacing.ts b/src/styles/utilities/spacing.ts index b635b7cc39a6..f0fbe4b4591a 100644 --- a/src/styles/utilities/spacing.ts +++ b/src/styles/utilities/spacing.ts @@ -207,6 +207,10 @@ export default { marginTop: 'auto', }, + mtn6: { + marginTop: -24, + }, + mb0: { marginBottom: 0, },