Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1542,14 +1542,11 @@ function navigateToConciergeChat(ignoreConciergeReportID = false) {
* @param {String} policyID
* @param {String} reportName
* @param {String} visibility
* @param {Array<Number>} policyMembersAccountIDs
* @param {String} writeCapability
* @param {String} welcomeMessage
*/
function addPolicyReport(policyID, reportName, visibility, policyMembersAccountIDs, writeCapability = CONST.REPORT.WRITE_CAPABILITIES.ALL, welcomeMessage = '') {
// The participants include the current user (admin), and for restricted rooms, the policy members. Participants must not be empty.
const members = visibility === CONST.REPORT.VISIBILITY.RESTRICTED ? policyMembersAccountIDs : [];

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here, we only add policy members for restricted room

const participants = _.unique([currentUserAccountID, ...members]);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parasharrajat Let's see the old logic here, we always add the current user to the member list here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, Sorry. What an oversight. Thanks for bringing this up.

function addPolicyReport(policyID, reportName, visibility, writeCapability = CONST.REPORT.WRITE_CAPABILITIES.ALL, welcomeMessage = '') {
const participants = [currentUserAccountID];
const parsedWelcomeMessage = ReportUtils.getParsedComment(welcomeMessage);
const policyReport = ReportUtils.buildOptimisticChatReport(
participants,
Expand Down
11 changes: 1 addition & 10 deletions src/pages/workspace/WorkspaceNewRoomPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import Permissions from '@libs/Permissions';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReportUtils from '@libs/ReportUtils';
import * as ValidationUtils from '@libs/ValidationUtils';
import policyMemberPropType from '@pages/policyMemberPropType';
import useThemeStyles from '@styles/useThemeStyles';
import variables from '@styles/variables';
import * as App from '@userActions/App';
Expand Down Expand Up @@ -61,17 +60,13 @@ const propTypes = {
}),
),

/** A collection of objects for all policies which key policy member objects by accountIDs */
allPolicyMembers: PropTypes.objectOf(PropTypes.objectOf(policyMemberPropType)),

/** Whether navigation is focused */
isFocused: PropTypes.bool.isRequired,
};
const defaultProps = {
betas: [],
reports: {},
policies: {},
allPolicyMembers: {},
};

function WorkspaceNewRoomPage(props) {
Expand All @@ -95,8 +90,7 @@ function WorkspaceNewRoomPage(props) {
* @param {Object} values - form input values passed by the Form component
*/
const submit = (values) => {
const policyMembers = _.map(_.keys(props.allPolicyMembers[`${ONYXKEYS.COLLECTION.POLICY_MEMBERS}${values.policyID}`]), (accountID) => Number(accountID));
Report.addPolicyReport(policyID, values.roomName, visibility, policyMembers, writeCapability, values.welcomeMessage);
Report.addPolicyReport(policyID, values.roomName, visibility, writeCapability, values.welcomeMessage);
};

useEffect(() => {
Expand Down Expand Up @@ -271,8 +265,5 @@ export default compose(
reports: {
key: ONYXKEYS.COLLECTION.REPORT,
},
allPolicyMembers: {
key: ONYXKEYS.COLLECTION.POLICY_MEMBERS,
},
}),
)(WorkspaceNewRoomPage);