@@ -20,11 +20,11 @@ import Navigation from '@libs/Navigation/Navigation';
2020import { rand64 } from '@libs/NumberUtils' ;
2121import { getDisplayNameOrDefault } from '@libs/PersonalDetailsUtils' ;
2222import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper' ;
23- import type { SpendRuleCategory } from '@src/types/form/SpendRuleForm' ;
2423import CONST from '@src/CONST' ;
2524import type { TranslationPaths } from '@src/languages/types' ;
2625import ONYXKEYS from '@src/ONYXKEYS' ;
2726import ROUTES from '@src/ROUTES' ;
27+ import type { SpendRuleCategory } from '@src/types/form/SpendRuleForm' ;
2828import SpendRuleRestrictionTypeToggle from './SpendRuleRestrictionTypeToggle' ;
2929import getTruncatedSpendRuleSummary from './SpendRuleSummaryUtils' ;
3030
@@ -69,20 +69,6 @@ function SpendRulePageBase({policyID, titleKey, testID}: SpendRulePageBaseProps)
6969 setIsErrorVisible ( false ) ;
7070 } ;
7171
72- const cardsMenuTitle = ! cardIDs ?. length
73- ? ''
74- : cardIDs
75- . map ( ( id ) => {
76- const card = cardsList ?. [ id ] ;
77- if ( card === undefined ) {
78- return id ;
79- }
80- const accountID = card . accountID ?? CONST . DEFAULT_NUMBER_ID ;
81- const displayName = getDisplayNameOrDefault ( personalDetails ?. [ accountID ] , '' , false ) ;
82- return getCardDescriptionForSearchTable ( card , displayName || undefined ) || id ;
83- } )
84- . join ( ', ' ) ;
85-
8672 const selectedCurrency = getSelectedCardsSharedCurrency ( cardIDs , cardsList ) ;
8773 const parsedMaxAmount = Number . parseFloat ( maxAmount ) ;
8874 const maxAmountMenuTitle = Number . isFinite ( parsedMaxAmount ) ? convertToDisplayString ( convertToBackendAmount ( parsedMaxAmount ) , selectedCurrency ?? CONST . CURRENCY . USD ) : '' ;
@@ -100,6 +86,21 @@ function SpendRulePageBase({policyID, titleKey, testID}: SpendRulePageBaseProps)
10086 Navigation . navigate ( ROUTES . RULES_SPEND_CARD . getRoute ( policyID ) ) ;
10187 } ;
10288
89+ function getCardsMenuTitle ( cardIDsToSummarize : string [ ] | undefined ) : string {
90+ return getTruncatedSpendRuleSummary (
91+ cardIDsToSummarize ?. map ( ( id ) => {
92+ const card = cardsList ?. [ id ] ;
93+ if ( card === undefined ) {
94+ return id ;
95+ }
96+ const accountID = card . accountID ?? CONST . DEFAULT_NUMBER_ID ;
97+ const displayName = getDisplayNameOrDefault ( personalDetails ?. [ accountID ] , '' , false ) ;
98+ return getCardDescriptionForSearchTable ( card , displayName || undefined ) || id ;
99+ } ) ,
100+ ( summary , count ) => translate ( 'workspace.rules.spendRules.summaryMoreCount' , { summary, count} ) ,
101+ ) ;
102+ }
103+
103104 function getMerchantMenuTitle ( merchantNamesToSummarize : string [ ] | undefined ) : string {
104105 return getTruncatedSpendRuleSummary ( merchantNamesToSummarize , ( summary , count ) => translate ( 'workspace.rules.spendRules.summaryMoreCount' , { summary, count} ) ) ;
105106 }
@@ -111,6 +112,7 @@ function SpendRulePageBase({policyID, titleKey, testID}: SpendRulePageBaseProps)
111112 ) ;
112113 }
113114
115+ const cardsMenuTitle = getCardsMenuTitle ( cardIDs ) ;
114116 const categoriesMenuTitle = getCategoryMenuTitle ( categories ) ;
115117
116118 const hasSelectedCards = ! ! cardIDs ?. length ;
@@ -158,6 +160,7 @@ function SpendRulePageBase({policyID, titleKey, testID}: SpendRulePageBaseProps)
158160 } }
159161 shouldShowRightIcon
160162 title = { cardsMenuTitle }
163+ numberOfLinesTitle = { 2 }
161164 titleStyle = { styles . flex1 }
162165 sentryLabel = { CONST . SENTRY_LABEL . WORKSPACE . RULES . MERCHANT_RULE_SECTION_ITEM }
163166 />
0 commit comments