Skip to content
Open
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
6 changes: 5 additions & 1 deletion src/components/Search/SearchList/BaseSearchList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function BaseSearchList({
flattenedItemsLength,
newTransactions,
selectedTransactions,
customCardNames,
}: BaseSearchListProps) {
const hasKeyBeenPressed = useRef(false);

Expand Down Expand Up @@ -102,7 +103,10 @@ function BaseSearchList({
return () => removeKeyDownPressListener(setHasKeyBeenPressed);
}, [setHasKeyBeenPressed]);

const extraData = useMemo(() => [focusedIndex, isFocused, columns, newTransactions, selectedTransactions], [focusedIndex, isFocused, columns, newTransactions, selectedTransactions]);
const extraData = useMemo(
() => [focusedIndex, isFocused, columns, newTransactions, selectedTransactions, customCardNames],
[focusedIndex, isFocused, columns, newTransactions, selectedTransactions, customCardNames],
);

return (
<AnimatedFlashListComponent
Expand Down
3 changes: 3 additions & 0 deletions src/components/Search/SearchList/BaseSearchList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ type BaseSearchListProps = Pick<

/** Selected transactions for triggering re-render via extraData */
selectedTransactions?: SelectedTransactions;

/** Custom card names for triggering re-render via extraData */
customCardNames?: Record<number, string>;
};

export default BaseSearchListProps;
7 changes: 7 additions & 0 deletions src/components/Search/SearchList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ type SearchListProps = Pick<FlashListProps<SearchListItem>, 'onScroll' | 'conten
/** Violations indexed by transaction ID */
violations?: Record<string, TransactionViolations | undefined> | undefined;

/** Custom card names */
customCardNames?: Record<number, string>;

/** Callback to fire when DEW modal should be opened */
onDEWModalOpen?: () => void;

Expand Down Expand Up @@ -175,6 +178,7 @@ function SearchList({
isMobileSelectionModeEnabled,
newTransactions = [],
violations,
customCardNames,
onDEWModalOpen,
selectedTransactions,
ref,
Expand Down Expand Up @@ -407,6 +411,7 @@ function SearchList({
accountID={accountID}
isOffline={isOffline}
violations={violations}
customCardNames={customCardNames}
onFocus={onFocus}
newTransactionID={newTransactionID}
/>
Expand Down Expand Up @@ -441,6 +446,7 @@ function SearchList({
isOffline,
violations,
onDEWModalOpen,
customCardNames,
],
);

Expand Down Expand Up @@ -500,6 +506,7 @@ function SearchList({
contentContainerStyle={contentContainerStyle}
newTransactions={newTransactions}
selectedTransactions={selectedTransactions}
customCardNames={customCardNames}
/>
<Modal
isVisible={isModalVisible}
Expand Down
2 changes: 2 additions & 0 deletions src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ function Search({
const {accountID, email} = useCurrentUserPersonalDetails();
const [isActionLoadingSet = new Set<string>()] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}`, {canBeMissing: true, selector: isActionLoadingSetSelector});
const [visibleColumns] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM, {canBeMissing: true, selector: columnsSelector});
const [customCardNames] = useOnyx(ONYXKEYS.NVP_EXPENSIFY_COMPANY_CARDS_CUSTOM_NAMES, {canBeMissing: true});

const isExpenseReportType = type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT;

Expand Down Expand Up @@ -1081,6 +1082,7 @@ function Search({
isMobileSelectionModeEnabled={isMobileSelectionModeEnabled}
shouldAnimate={type === CONST.SEARCH.DATA_TYPES.EXPENSE}
newTransactions={newTransactions}
customCardNames={customCardNames}
/>
<ConfirmModal
title={translate('customApprovalWorkflow.title')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function TransactionListItem<TItem extends ListItem>({
columns,
isLoading,
violations,
customCardNames,
onDEWModalOpen,
}: TransactionListItemProps<TItem>) {
const transactionItem = item as unknown as TransactionListItemType;
Expand Down Expand Up @@ -226,6 +227,7 @@ function TransactionListItem<TItem extends ListItem>({
violations={transactionViolations}
onArrowRightPress={onPress}
isHover={hovered}
customCardNames={customCardNames}
/>
</>
)}
Expand Down
1 change: 1 addition & 0 deletions src/components/SelectionListWithSections/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ type TransactionListItemProps<TItem extends ListItem> = ListItemProps<TItem> & {
isLoading?: boolean;
columns?: SearchColumnType[];
violations?: Record<string, TransactionViolations | undefined> | undefined;
customCardNames?: Record<number, string>;
/** Callback to fire when DEW modal should be opened */
onDEWModalOpen?: () => void;
};
Expand Down
19 changes: 17 additions & 2 deletions src/components/TransactionItemRow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ type TransactionItemRowProps = {
onArrowRightPress?: () => void;
isHover?: boolean;
shouldShowArrowRightOnNarrowLayout?: boolean;
customCardNames?: Record<number, string>;
};

function getMerchantName(transactionItem: TransactionWithOptionalSearchFields, translate: (key: TranslationPaths) => string) {
Expand Down Expand Up @@ -178,6 +179,7 @@ function TransactionItemRow({
onArrowRightPress,
isHover = false,
shouldShowArrowRightOnNarrowLayout,
customCardNames,
}: TransactionItemRowProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand Down Expand Up @@ -236,6 +238,17 @@ function TransactionItemRow({

const exchangeRateMessage = getExchangeRate(transactionItem);

const cardName = useMemo(() => {
if (transactionItem.cardName === CONST.EXPENSE.TYPE.CASH_CARD_NAME) {
return '';
}
const cardID = transactionItem.cardID;
if (cardID && customCardNames?.[cardID]) {
return customCardNames[cardID];
}
return transactionItem.cardName;
}, [transactionItem.cardID, transactionItem.cardName, customCardNames]);

const columnComponent = useMemo(
() => ({
[CONST.SEARCH.TABLE_COLUMNS.TYPE]: (
Expand Down Expand Up @@ -445,7 +458,7 @@ function TransactionItemRow({
key={CONST.SEARCH.TABLE_COLUMNS.CARD}
style={[StyleUtils.getReportTableColumnStyles(CONST.SEARCH.TABLE_COLUMNS.CARD)]}
>
<TextCell text={transactionItem.cardName === CONST.EXPENSE.TYPE.CASH_CARD_NAME ? '' : (transactionItem.cardName ?? '')} />
<TextCell text={cardName} />
</View>
),
[CONST.SEARCH.TABLE_COLUMNS.COMMENTS]: (
Expand Down Expand Up @@ -564,18 +577,20 @@ function TransactionItemRow({
report?.total,
isApprovedColumnWide,
isPostedColumnWide,
translate,
isExportedColumnWide,
translate,
isReportItemChild,
onButtonPress,
isActionLoading,
merchant,
description,
cardName,
isInSingleTransactionReport,
exchangeRateMessage,
isAmountColumnWide,
isTaxAmountColumnWide,
isLargeScreenWidth,
hash,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed now but wasn't needed earlier?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ShridharGoel I added by the suggestion from lint. Look like we missed it before.

],
);
const shouldRenderChatBubbleCell = useMemo(() => {
Expand Down
Loading