Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] New Room participants list is empty #21072

Merged
merged 5 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 3 additions & 2 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1152,10 +1152,11 @@ function navigateToConciergeChat() {
* @param {Object} policy
* @param {String} reportName
* @param {String} visibility
* @param {Array} policyMembers
*/
function addPolicyReport(policy, reportName, visibility) {
function addPolicyReport(policy, reportName, visibility, policyMembers) {
// The participants include the current user (admin) and the employees. Participants must not be empty.
const participants = _.unique([currentUserAccountID, ..._.pluck(policy.employeeList, 'accountID')]);
const participants = _.unique([currentUserAccountID, ...policyMembers]);
const policyReport = ReportUtils.buildOptimisticChatReport(
participants,
reportName,
Expand Down
11 changes: 10 additions & 1 deletion src/pages/workspace/WorkspaceNewRoomPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import * as ErrorUtils from '../../libs/ErrorUtils';
import * as ValidationUtils from '../../libs/ValidationUtils';
import Form from '../../components/Form';
import shouldDelayFocus from '../../libs/shouldDelayFocus';
import policyMemberPropType from '../policyMemberPropType';

const propTypes = {
/** All reports shared with the user */
Expand Down Expand Up @@ -52,12 +53,16 @@ const propTypes = {
}),
),

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

...withLocalizePropTypes,
};
const defaultProps = {
betas: [],
reports: {},
policies: {},
allPolicyMembers: {},
};

class WorkspaceNewRoomPage extends React.Component {
Expand All @@ -78,7 +83,8 @@ class WorkspaceNewRoomPage extends React.Component {
*/
submit(values) {
const policyID = this.props.policies[`${ONYXKEYS.COLLECTION.POLICY}${values.policyID}`];
Report.addPolicyReport(policyID, values.roomName, values.visibility);
const policyMembers = _.map(_.keys(this.props.allPolicyMembers[`${ONYXKEYS.COLLECTION.POLICY_MEMBERS}${values.policyID}`]), (accountID) => Number(accountID));
Report.addPolicyReport(policyID, values.roomName, values.visibility, policyMembers);
}

/**
Expand Down Expand Up @@ -202,6 +208,9 @@ export default compose(
reports: {
key: ONYXKEYS.COLLECTION.REPORT,
},
allPolicyMembers: {
key: ONYXKEYS.COLLECTION.POLICY_MEMBERS,
},
}),
withLocalize,
)(WorkspaceNewRoomPage);