Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/hooks/useCardFeeds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,15 @@ const useCardFeeds = (policyID: string | undefined): [CombinedCardFeeds | undefi
return acc;
}

// eslint-disable-next-line unicorn/no-array-for-each
Object.entries(feed.settings.companyCards).forEach(([key, feedSettings]) => {
for (const [key, feedSettings] of Object.entries(feed.settings.companyCards)) {
const feedName = key as CompanyCardFeed;
const feedOAuthAccountDetails = feed.settings.oAuthAccountDetails?.[feedName];
const feedCompanyCardNickname = feed.settings.companyCardNicknames?.[feedName];
const domainID = onyxKey.split('_').at(-1);
const shouldAddFeed = domainID && (feedSettings.preferredPolicy ? feedSettings.preferredPolicy === policyID : domainID === workspaceAccountID.toString());

if (!shouldAddFeed) {
return;
continue;
}

const combinedFeedKey = getCompanyCardFeedWithDomainID(feedName, domainID);
Expand All @@ -70,7 +69,7 @@ const useCardFeeds = (policyID: string | undefined): [CombinedCardFeeds | undefi
domainID: Number(domainID),
feed: feedName,
};
});
}

return acc;
}, result);
Expand Down
16 changes: 9 additions & 7 deletions src/hooks/useDuplicateTransactionsAndViolations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,14 @@ function selectTransactionsWithDuplicates(
continue;
}

transactionViolations
.filter((violations) => violations.name === CONST.VIOLATIONS.DUPLICATED_TRANSACTION)
.flatMap((violations) => violations?.data?.duplicates ?? [])
// eslint-disable-next-line unicorn/no-array-for-each
.forEach((duplicateID) => {
for (const violation of transactionViolations) {
if (violation.name !== CONST.VIOLATIONS.DUPLICATED_TRANSACTION) {
continue;
}

for (const duplicateID of violation.data?.duplicates ?? []) {
if (!duplicateID) {
return;
continue;
}

const duplicateKey = `${ONYXKEYS.COLLECTION.TRANSACTION}${duplicateID}`;
Expand All @@ -97,7 +98,8 @@ function selectTransactionsWithDuplicates(
if (duplicateTransaction) {
result[duplicateKey] = duplicateTransaction;
}
});
}
}
}
return result;
}
Expand Down
12 changes: 5 additions & 7 deletions src/libs/CardFeedUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,12 @@ function getCardFeedsForDisplay(allCardFeeds: OnyxCollection<CardFeeds>, allCard
continue;
}

// eslint-disable-next-line unicorn/no-array-for-each
Object.keys(getOriginalCompanyFeeds(cardFeeds)).forEach((key) => {
for (const key of Object.keys(getOriginalCompanyFeeds(cardFeeds))) {
const feed = key as CompanyCardFeed;
const id = `${fundID}_${feed}`;

if (cardFeedsForDisplay[id]) {
return;
continue;
}

cardFeedsForDisplay[id] = {
Expand All @@ -439,7 +438,7 @@ function getCardFeedsForDisplay(allCardFeeds: OnyxCollection<CardFeeds>, allCard
fundID,
name: getCustomOrFormattedFeedName(feed, cardFeeds?.settings?.companyCardNicknames?.[feed], false) ?? feed,
};
});
}
}

for (const card of Object.values(allCards)) {
Expand Down Expand Up @@ -479,8 +478,7 @@ function getCardFeedsForDisplayPerPolicy(allCardFeeds: OnyxCollection<CardFeeds>
continue;
}

// eslint-disable-next-line unicorn/no-array-for-each
Object.entries(getOriginalCompanyFeeds(cardFeeds)).forEach(([key, feedData]) => {
for (const [key, feedData] of Object.entries(getOriginalCompanyFeeds(cardFeeds))) {
const preferredPolicy = 'preferredPolicy' in feedData ? (feedData.preferredPolicy ?? '') : '';
const feed = key as CompanyCardFeed;
const id = `${fundID}_${feed}`;
Expand All @@ -491,7 +489,7 @@ function getCardFeedsForDisplayPerPolicy(allCardFeeds: OnyxCollection<CardFeeds>
fundID,
name: getCustomOrFormattedFeedName(feed, cardFeeds?.settings?.companyCardNicknames?.[feed], false) ?? feed,
});
});
}
}

return cardFeedsForDisplayPerPolicy;
Expand Down
14 changes: 10 additions & 4 deletions src/libs/CategoryOptionListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,22 @@ function getCategoryOptionTree(options: Record<string, Category> | Category[], i
continue;
}

// eslint-disable-next-line unicorn/no-array-for-each
option.name.split(CONST.PARENT_CHILD_SEPARATOR).forEach((optionName, index, array) => {
const array = option.name.split(CONST.PARENT_CHILD_SEPARATOR);

for (let index = 0; index < array.length; index++) {
const optionName = array.at(index);
if (!optionName) {
continue;
}

const indents = times(index, () => CONST.INDENTS).join('');
const isChild = array.length - 1 === index;
const searchText = array.slice(0, index + 1).join(CONST.PARENT_CHILD_SEPARATOR);
const selectedParentOption = !isChild && Object.values(selectedOptions).find((op) => op.name === searchText);
const isParentOptionDisabled = !selectedParentOption || !selectedParentOption.enabled || selectedParentOption.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;

if (optionCollection.has(searchText)) {
return;
continue;
}

const decodedCategoryName = getDecodedCategoryName(optionName);
Expand All @@ -77,7 +83,7 @@ function getCategoryOptionTree(options: Record<string, Category> | Category[], i
isSelected: isChild ? !!option.isSelected : !!selectedParentOption,
pendingAction: option.pendingAction,
});
});
}
}

return Array.from(optionCollection.values());
Expand Down
Loading