Skip to content

Commit

Permalink
fix optimistic members of restricted room
Browse files Browse the repository at this point in the history
  • Loading branch information
dukenv0307 committed Nov 20, 2023
1 parent ff4c947 commit d181fd7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
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 : [];
const participants = _.unique([currentUserAccountID, ...members]);
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);

0 comments on commit d181fd7

Please sign in to comment.