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

Add employeeList to local policy after creation #3947

Merged
merged 1 commit into from
Jul 9, 2021
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
11 changes: 6 additions & 5 deletions src/libs/actions/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ function getSimplifiedPolicyObject(fullPolicy) {
}

/**
* Simplifies the policyList response into an object containing an array of emails
* Simplifies the employeeList response into an object containing an array of emails
*
* @param {Object} fullPolicy
* @param {Object} employeeList
* @returns {Array}
*/
function getSimplifiedEmployeeList(fullPolicy) {
const employeeListEmails = _.chain(fullPolicy.value.employeeList)
function getSimplifiedEmployeeList(employeeList) {
const employeeListEmails = _.chain(employeeList)
.pluck('email')
.flatten()
.unique()
Expand Down Expand Up @@ -82,7 +82,7 @@ function getPolicyList() {
const policyDataToStore = _.reduce(data.policyList, (memo, policy) => ({
...memo,
[`${ONYXKEYS.COLLECTION.POLICY}${policy.id}`]: {
employeeList: getSimplifiedEmployeeList(policy),
employeeList: getSimplifiedEmployeeList(policy.value.employeeList),
avatarURL: lodashGet(policy, 'value.avatarURL', ''),
},
}), {});
Expand Down Expand Up @@ -193,6 +193,7 @@ function create(name) {
}

Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${response.policyID}`, {
employeeList: getSimplifiedEmployeeList(response.policy.employeeList),
id: response.policyID,
type: response.policy.type,
name: response.policy.name,
Expand Down