diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 2b49fb8b7dce..93b9af771a32 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -1957,6 +1957,32 @@ function startSplitBill(participants, currentUserLogin, currentUserAccountID, co }); }); + _.each(participants, (participant) => { + const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(participant); + if (!isPolicyExpenseChat) { + return; + } + + const optimisticPolicyRecentlyUsedCategories = Policy.buildOptimisticPolicyRecentlyUsedCategories(participant.policyID, category); + const optimisticPolicyRecentlyUsedTags = Policy.buildOptimisticPolicyRecentlyUsedTags(participant.policyID, tag); + + if (!_.isEmpty(optimisticPolicyRecentlyUsedCategories)) { + optimisticData.push({ + onyxMethod: Onyx.METHOD.SET, + key: `${ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_CATEGORIES}${participant.policyID}`, + value: optimisticPolicyRecentlyUsedCategories, + }); + } + + if (!_.isEmpty(optimisticPolicyRecentlyUsedTags)) { + optimisticData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS}${participant.policyID}`, + value: optimisticPolicyRecentlyUsedTags, + }); + } + }); + // Save the new splits array into the transaction's comment in case the user calls CompleteSplitBill while offline optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE,