diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index 4df510d44db7..de6afe5a3dd1 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -1048,8 +1048,10 @@ function generateCustomUnitID() { * @returns {Object} */ function buildOptimisticCustomUnits() { + const currency = lodashGet(allPersonalDetails, [sessionAccountID, 'localCurrencyCode'], CONST.CURRENCY.USD); const customUnitID = generateCustomUnitID(); const customUnitRateID = generateCustomUnitID(); + const customUnits = { [customUnitID]: { customUnitID, @@ -1062,6 +1064,7 @@ function buildOptimisticCustomUnits() { customUnitRateID, name: CONST.CUSTOM_UNITS.DEFAULT_RATE, rate: CONST.CUSTOM_UNITS.MILEAGE_IRS_RATE * CONST.POLICY.CUSTOM_UNIT_RATE_BASE_OFFSET, + currency, }, }, }, @@ -1071,6 +1074,7 @@ function buildOptimisticCustomUnits() { customUnits, customUnitID, customUnitRateID, + outputCurrency: currency, }; } @@ -1084,7 +1088,7 @@ function buildOptimisticCustomUnits() { */ function createDraftInitialWorkspace(policyOwnerEmail = '', policyName = '', policyID = generatePolicyID(), makeMeAdmin = false) { const workspaceName = policyName || generateDefaultWorkspaceName(policyOwnerEmail); - const {customUnits} = buildOptimisticCustomUnits(); + const {customUnits, outputCurrency} = buildOptimisticCustomUnits(); const optimisticData = [ { @@ -1097,7 +1101,7 @@ function createDraftInitialWorkspace(policyOwnerEmail = '', policyName = '', pol role: CONST.POLICY.ROLE.ADMIN, owner: sessionEmail, isPolicyExpenseChatEnabled: true, - outputCurrency: lodashGet(allPersonalDetails, [sessionAccountID, 'localCurrencyCode'], CONST.CURRENCY.USD), + outputCurrency, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, customUnits, makeMeAdmin, @@ -1130,7 +1134,7 @@ function createDraftInitialWorkspace(policyOwnerEmail = '', policyName = '', pol function createWorkspace(policyOwnerEmail = '', makeMeAdmin = false, policyName = '', policyID = generatePolicyID()) { const workspaceName = policyName || generateDefaultWorkspaceName(policyOwnerEmail); - const {customUnits, customUnitID, customUnitRateID} = buildOptimisticCustomUnits(); + const {customUnits, customUnitID, customUnitRateID, outputCurrency} = buildOptimisticCustomUnits(); const { announceChatReportID, @@ -1176,7 +1180,7 @@ function createWorkspace(policyOwnerEmail = '', makeMeAdmin = false, policyName role: CONST.POLICY.ROLE.ADMIN, owner: sessionEmail, isPolicyExpenseChatEnabled: true, - outputCurrency: lodashGet(allPersonalDetails, [sessionAccountID, 'localCurrencyCode'], CONST.CURRENCY.USD), + outputCurrency, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, customUnits, },