Skip to content

Commit

Permalink
Merge pull request #30676 from dukenv0307/fix/29454
Browse files Browse the repository at this point in the history
fix: should not be able to set welcome message for threads created from policy room
  • Loading branch information
chiragsalian authored Nov 15, 2023
2 parents f7df55f + 36b7d9e commit 1ca499c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
10 changes: 10 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4196,6 +4196,15 @@ function getRoom(type, policyID) {
const room = _.find(allReports, (report) => report && report.policyID === policyID && report.chatType === type && !isThread(report));
return room;
}
/**
* We only want policy owners and admins to be able to modify the welcome message, but not in thread chat.
* @param {Object} report
* @param {Object} policy
* @return {Boolean}
*/
function shouldDisableWelcomeMessage(report, policy) {
return isMoneyRequestReport(report) || isArchivedRoom(report) || !isChatRoom(report) || isChatThread(report) || !PolicyUtils.isPolicyAdmin(policy);
}

export {
getReportParticipantsTitle,
Expand Down Expand Up @@ -4358,4 +4367,5 @@ export {
getReimbursementQueuedActionMessage,
getPersonalDetailsForAccountID,
getRoom,
shouldDisableWelcomeMessage,
};
4 changes: 2 additions & 2 deletions src/pages/ReportWelcomeMessagePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import TextInput from '@components/TextInput';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import compose from '@libs/compose';
import Navigation from '@libs/Navigation/Navigation';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReportUtils from '@libs/ReportUtils';
import updateMultilineInputRange from '@libs/UpdateMultilineInputRange';
import styles from '@styles/styles';
import * as Report from '@userActions/Report';
Expand Down Expand Up @@ -80,7 +80,7 @@ function ReportWelcomeMessagePage(props) {
includeSafeAreaPaddingBottom={false}
testID={ReportWelcomeMessagePage.displayName}
>
<FullPageNotFoundView shouldShow={!PolicyUtils.isPolicyAdmin(props.policy)}>
<FullPageNotFoundView shouldShow={ReportUtils.shouldDisableWelcomeMessage(props.report, props.policy)}>
<HeaderWithBackButton
title={props.translate('welcomeMessagePage.welcomeMessage')}
onBackButtonPress={() => Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(props.report.reportID))}
Expand Down
5 changes: 2 additions & 3 deletions src/pages/settings/Report/ReportSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ function ReportSettingsPage(props) {
const shouldDisableRename = useMemo(() => ReportUtils.shouldDisableRename(report, linkedWorkspace), [report, linkedWorkspace]);
const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report);

// We only want policy owners and admins to be able to modify the welcome message.
const shouldDisableWelcomeMessage =
isMoneyRequestReport || ReportUtils.isArchivedRoom(report) || !ReportUtils.isChatRoom(report) || _.isEmpty(linkedWorkspace) || linkedWorkspace.role !== CONST.POLICY.ROLE.ADMIN;
// We only want policy owners and admins to be able to modify the welcome message, but not in thread chat
const shouldDisableWelcomeMessage = ReportUtils.shouldDisableWelcomeMessage(report, linkedWorkspace);

const shouldDisableSettings = _.isEmpty(report) || ReportUtils.isArchivedRoom(report);
const shouldShowRoomName = !ReportUtils.isPolicyExpenseChat(report) && !ReportUtils.isChatThread(report);
Expand Down

0 comments on commit 1ca499c

Please sign in to comment.