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 hidden members is shown when creating workspace from iou payment #52296

Merged
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
15 changes: 10 additions & 5 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2143,7 +2143,6 @@ function createWorkspaceFromIOUPayment(iouReport: OnyxEntry<Report>): WorkspaceF
const policyID = generatePolicyID();
const workspaceName = generateDefaultWorkspaceName(sessionEmail);
const employeeAccountID = iouReport.ownerAccountID;
const employeeEmail = iouReport.ownerEmail ?? '';
const {customUnits, customUnitID, customUnitRateID} = buildOptimisticDistanceRateCustomUnits(iouReport.currency);
const oldPersonalPolicyID = iouReport.policyID;
const iouReportID = iouReport.reportID;
Expand All @@ -2163,6 +2162,8 @@ function createWorkspaceFromIOUPayment(iouReport: OnyxEntry<Report>): WorkspaceF
return;
}

const employeeEmail = allPersonalDetails?.[employeeAccountID]?.login ?? '';

// Create the workspace chat for the employee whose IOU is being paid
const employeeWorkspaceChat = createPolicyExpenseChats(policyID, {[employeeEmail]: employeeAccountID}, true);
const newWorkspace = {
Expand Down Expand Up @@ -2197,10 +2198,14 @@ function createWorkspaceFromIOUPayment(iouReport: OnyxEntry<Report>): WorkspaceF
role: CONST.POLICY.ROLE.ADMIN,
errors: {},
},
[employeeEmail]: {
role: CONST.POLICY.ROLE.USER,
errors: {},
},
...(employeeEmail
? {
[employeeEmail]: {
role: CONST.POLICY.ROLE.USER,
errors: {},
},
}
: {}),
},
pendingFields: {
autoReporting: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
Expand Down
Loading