Skip to content

Commit

Permalink
Merge pull request #3947 from rdjuric/fixPolicyMerge
Browse files Browse the repository at this point in the history
Add employeeList to local policy after creation
  • Loading branch information
NikkiWines authored Jul 9, 2021
2 parents ee2f84f + 1cf73db commit 0be2f95
Showing 1 changed file with 6 additions and 5 deletions.
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

0 comments on commit 0be2f95

Please sign in to comment.