From 1cf73dbf64f3734dd5161c0b52590406e473c12c Mon Sep 17 00:00:00 2001 From: Rafael Date: Fri, 9 Jul 2021 03:55:12 -0300 Subject: [PATCH] add employeeList to local policy after creation --- src/libs/actions/Policy.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index 08ff8887387b..287ee73d2dbd 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -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() @@ -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', ''), }, }), {}); @@ -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,