Skip to content

Commit e07b862

Browse files
Hide deactivated cards from spend rule summaries and selection
Filter out deactivated/inactive card IDs before building display summaries in SpendRulesSection and SpendRulePageBase. Rules with only deactivated cards are hidden entirely from the rules list. Co-authored-by: Carlos Martins <luacmartins@users.noreply.github.com>
1 parent 410fb76 commit e07b862

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/pages/workspace/rules/SpendRules/SpendRulePageBase.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ function SpendRulePageBase({policyID, ruleID, titleKey, testID}: SpendRulePageBa
107107
};
108108

109109
function getCardsMenuTitle(cardIDsToSummarize: string[] | undefined): string {
110+
const activeCardIDs = cardIDsToSummarize?.filter((id) => cardsList?.[id] !== undefined);
110111
return getTruncatedSpendRuleSummary(
111-
cardIDsToSummarize?.map((id) => {
112+
activeCardIDs?.map((id) => {
112113
const card = cardsList?.[id];
113114
if (card === undefined) {
114115
return id;

src/pages/workspace/rules/SpendRules/SpendRulesSection.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,16 @@ function SpendRulesSection({policyID}: SpendRulesSectionProps) {
123123
return undefined;
124124
}
125125
const actionLabel = formValues.restrictionAction === CONST.SPEND_RULES.ACTION.BLOCK ? blockLabel : allowLabel;
126-
const selectedCurrency = getSelectedCardsSharedCurrency(formValues.cardIDs, cardsList);
126+
const activeCardIDs = formValues.cardIDs.filter((cardID) => {
127+
const card = cardsList?.[cardID];
128+
return card && isCard(card);
129+
});
130+
if (activeCardIDs.length === 0) {
131+
return undefined;
132+
}
133+
const selectedCurrency = getSelectedCardsSharedCurrency(activeCardIDs, cardsList);
127134
const cardSummary = getTruncatedSpendRuleSummary(
128-
formValues.cardIDs.map((cardID) => {
135+
activeCardIDs.map((cardID) => {
129136
const card = cardsList?.[cardID];
130137
if (!card || !isCard(card)) {
131138
return cardID;

0 commit comments

Comments
 (0)