Skip to content

Commit

Permalink
fix: move check
Browse files Browse the repository at this point in the history
  • Loading branch information
BeeMargarida committed Sep 29, 2023
1 parent e011efb commit 7e1956f
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,7 @@ let allPolicyTags = {};
Onyx.connect({
key: ONYXKEYS.COLLECTION.POLICY_TAGS,
waitForCollectionCallback: true,
callback: (value) => {
if (!value) {
allPolicyTags = {};
return;
}

allPolicyTags = value;
},
callback: (value) => (allPolicyTags = value),
});

let userAccountID = '';
Expand Down Expand Up @@ -507,10 +500,12 @@ function getMoneyRequestInformation(
const policyTags = allPolicyTags[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${iouReport.policyID}`];
const recentlyUsedPolicyTags = allRecentlyUsedTags[`${ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS}${iouReport.policyID}`];

// For now it only uses the first tag of the policy, since multi-tags are not yet supported
const tagListKey = _.first(_.keys(policyTags));
const uniquePolicyRecentlyUsedTags = recentlyUsedPolicyTags ? _.filter(recentlyUsedPolicyTags[tagListKey], (recentlyUsedPolicyTag) => recentlyUsedPolicyTag !== tag) : [];
optimisticPolicyRecentlyUsedTags[tagListKey] = [tag, ...uniquePolicyRecentlyUsedTags];
if (policyTags) {
// For now it only uses the first tag of the policy, since multi-tags are not yet supported
const tagListKey = _.first(_.keys(policyTags));
const uniquePolicyRecentlyUsedTags = recentlyUsedPolicyTags ? _.filter(recentlyUsedPolicyTags[tagListKey], (recentlyUsedPolicyTag) => recentlyUsedPolicyTag !== tag) : [];
optimisticPolicyRecentlyUsedTags[tagListKey] = [tag, ...uniquePolicyRecentlyUsedTags];
}

// If there is an existing transaction (which is the case for distance requests), then the data from the existing transaction
// needs to be manually merged into the optimistic transaction. This is because buildOnyxDataForMoneyRequest() uses `Onyx.set()` for the transaction
Expand Down

0 comments on commit 7e1956f

Please sign in to comment.