Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import canUseTouchScreen from '@libs/DeviceCapabilities/canUseTouchScreen';
import {getTransactionPendingAction, isTransactionPendingDelete} from '@libs/TransactionUtils';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import type {Policy, Report} from '@src/types/onyx';
import type {CardList, Policy, Report} from '@src/types/onyx';
import type {TransactionWithOptionalHighlight} from './MoneyRequestReportTransactionList';

type MoneyRequestReportTransactionItemProps = {
Expand Down Expand Up @@ -67,8 +67,8 @@ type MoneyRequestReportTransactionItemProps = {
/** Whether this transaction should be highlighted as newly added */
shouldBeHighlighted: boolean;

/** Custom card names mapping cardID to display name */
customCardNames?: Record<number, string>;
/** List of cards for the user */
nonPersonalAndWorkspaceCards: CardList;
};

function MoneyRequestReportTransactionItem({
Expand All @@ -87,7 +87,7 @@ function MoneyRequestReportTransactionItem({
scrollToNewTransaction,
onArrowRightPress,
shouldBeHighlighted,
customCardNames,
nonPersonalAndWorkspaceCards,
}: MoneyRequestReportTransactionItemProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
Expand Down Expand Up @@ -165,7 +165,7 @@ function MoneyRequestReportTransactionItem({
}}
onArrowRightPress={() => onArrowRightPress?.(transaction.transactionID)}
isHover={hovered}
customCardNames={customCardNames}
nonPersonalAndWorkspaceCards={nonPersonalAndWorkspaceCards}
/>
)}
</PressableWithFeedback>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ type MoneyRequestReportTransactionListProps = {
type TransactionWithOptionalHighlight = OnyxTypes.Transaction & {
/** Whether the transaction should be highlighted, when it is added to the report */
shouldBeHighlighted?: boolean;

/** Whether the card feed has been deleted */
isCardFeedDeleted?: boolean;
};

type ReportScreenNavigationProps = ReportsSplitNavigatorParamList[typeof SCREENS.REPORT];
Expand Down Expand Up @@ -170,8 +167,7 @@ function MoneyRequestReportTransactionList({
const [reportDetailsColumns] = useOnyx(ONYXKEYS.NVP_REPORT_DETAILS_COLUMNS);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [cardFeeds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER);
const [customCardNames] = useOnyx(ONYXKEYS.NVP_EXPENSIFY_COMPANY_CARDS_CUSTOM_NAMES);
const [nonPersonalAndWorkspaceCards] = useOnyx(ONYXKEYS.DERIVED.NON_PERSONAL_AND_WORKSPACE_CARD_LIST);
const [cardList] = useOnyx(ONYXKEYS.CARD_LIST);
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});

Expand Down Expand Up @@ -249,7 +245,7 @@ function MoneyRequestReportTransactionList({
);
}, [sortBy, sortOrder, transactions, localeCompare, report, policy]);

const resolvedTransactions = useMemo(() => resolveTransactionCardFields(sortedTransactions, cardList, cardFeeds, translate), [sortedTransactions, cardList, cardFeeds, translate]);
const resolvedTransactions = useMemo(() => resolveTransactionCardFields(sortedTransactions, cardList, translate), [sortedTransactions, cardList, translate]);

const highlightedTransactionIDs = useMemo(() => new Set(newTransactions.map(({transactionID}) => transactionID)), [newTransactions]);

Expand Down Expand Up @@ -566,7 +562,7 @@ function MoneyRequestReportTransactionList({
taxAmountColumnSize={taxAmountColumnSize}
scrollToNewTransaction={transaction.transactionID === newTransactions?.at(0)?.transactionID ? scrollToNewTransaction : undefined}
onArrowRightPress={handleArrowRightPress}
customCardNames={customCardNames}
nonPersonalAndWorkspaceCards={nonPersonalAndWorkspaceCards ?? {}}
/>
);
})}
Expand All @@ -591,7 +587,7 @@ function MoneyRequestReportTransactionList({
taxAmountColumnSize={taxAmountColumnSize}
scrollToNewTransaction={transaction.transactionID === newTransactions?.at(0)?.transactionID ? scrollToNewTransaction : undefined}
onArrowRightPress={handleArrowRightPress}
customCardNames={customCardNames}
nonPersonalAndWorkspaceCards={nonPersonalAndWorkspaceCards ?? {}}
/>
))}
</View>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Search/SearchList/BaseSearchList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import {isMobileChrome} from '@libs/Browser';
import {addKeyDownPressListener, removeKeyDownPressListener} from '@libs/KeyboardShortcut/KeyDownPressListener';
import CONST from '@src/CONST';
import type {SearchListItem} from '../ListItem/types';

Check warning on line 12 in src/components/Search/SearchList/BaseSearchList/index.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Unexpected parent import '../ListItem/types'. Use '@components/Search/SearchList/ListItem/types' instead

Check warning on line 12 in src/components/Search/SearchList/BaseSearchList/index.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unexpected parent import '../ListItem/types'. Use '@components/Search/SearchList/ListItem/types' instead
import type BaseSearchListProps from './types';

const AnimatedFlashListComponent = Animated.createAnimatedComponent(FlashList<SearchListItem>);
Expand All @@ -32,7 +32,7 @@
flattenedItemsLength,
newTransactions,
selectedTransactions,
customCardNames,
nonPersonalAndWorkspaceCards,
}: BaseSearchListProps) {
const hasKeyBeenPressed = useRef(false);
const isFocused = useIsFocused();
Expand Down Expand Up @@ -106,8 +106,8 @@
}, [setHasKeyBeenPressed]);

const extraData = useMemo(
() => [focusedIndex, columns, newTransactions, selectedTransactions, customCardNames],
[focusedIndex, columns, newTransactions, selectedTransactions, customCardNames],
() => [focusedIndex, columns, newTransactions, selectedTransactions, nonPersonalAndWorkspaceCards],
[focusedIndex, columns, newTransactions, selectedTransactions, nonPersonalAndWorkspaceCards],
Comment thread
JS00001 marked this conversation as resolved.
);

return (
Expand Down
6 changes: 3 additions & 3 deletions src/components/Search/SearchList/BaseSearchList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {NativeSyntheticEvent} from 'react-native';
import type {SearchListItem} from '@components/Search/SearchList/ListItem/types';
import type {SearchColumnType, SelectedTransactions} from '@components/Search/types';
import type {ExtendedTargetedEvent} from '@components/SelectionList/ListItem/types';
import type {Transaction} from '@src/types/onyx';
import type {CardList, Transaction} from '@src/types/onyx';

type BaseSearchListProps = Pick<
FlashListProps<SearchListItem>,
Expand Down Expand Up @@ -45,8 +45,8 @@ 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>;
/** Non-personal and workspace cards for triggering re-render via extraData */
nonPersonalAndWorkspaceCards?: CardList;
};

export default BaseSearchListProps;
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function TransactionGroupListExpanded<TItem extends ListItem>({
searchTransactions,
isInSingleTransactionReport,
onLongPress,
nonPersonalAndWorkspaceCards,
onUndelete,
}: TransactionGroupListExpandedProps<TItem>) {
const theme = useTheme();
Expand Down Expand Up @@ -249,6 +250,7 @@ function TransactionGroupListExpanded<TItem extends ListItem>({
onArrowRightPress={isDeletedTransaction(transaction) ? undefined : () => openReportInRHP(transaction)}
shouldShowArrowRightOnNarrowLayout
reportActions={exportedReportActions}
nonPersonalAndWorkspaceCards={nonPersonalAndWorkspaceCards}
/>
);
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function TransactionGroupListItem<TItem extends ListItem>({
newTransactionID,
lastPaymentMethod,
personalPolicyID,
nonPersonalAndWorkspaceCards,
isFirstItem,
isLastItem,
userBillingGracePeriodEnds,
Expand Down Expand Up @@ -575,6 +576,7 @@ function TransactionGroupListItem<TItem extends ListItem>({
searchTransactions={searchTransactions}
isInSingleTransactionReport={groupItem.transactions.length === 1}
onLongPress={onExpandedRowLongPress}
nonPersonalAndWorkspaceCards={nonPersonalAndWorkspaceCards}
onUndelete={onUndelete}
/>
</AnimatedCollapsible>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function TransactionListItem<TItem extends ListItem>({
columns,
isLoading,
violations,
customCardNames,
nonPersonalAndWorkspaceCards,
lastPaymentMethod,
personalPolicyID,
isLastItem,
Expand Down Expand Up @@ -256,7 +256,7 @@ function TransactionListItem<TItem extends ListItem>({
violations={transactionViolations}
onArrowRightPress={isDeletedTransaction ? undefined : () => onSelectRow(item, transactionPreviewData)}
isHover={hovered}
customCardNames={customCardNames}
nonPersonalAndWorkspaceCards={nonPersonalAndWorkspaceCards}
reportActions={exportedReportActions}
/>
</>
Expand Down
11 changes: 6 additions & 5 deletions src/components/Search/SearchList/ListItem/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {ListItem} from '@components/SelectionList/types';
import type CONST from '@src/CONST';
import type {
BillingGraceEndPeriod,
CardList,
LastPaymentMethod,
PersonalDetails,
PersonalDetailsList,
Expand Down Expand Up @@ -118,9 +119,6 @@ type TransactionListItemType = ListItem &
/** final and formatted "merchant" value used for displaying and sorting */
formattedMerchant: string;

/** Whether the card feed has been deleted */
isCardFeedDeleted?: boolean;

/** The original amount of the transaction */
originalAmount?: number;

Expand Down Expand Up @@ -423,7 +421,8 @@ type TransactionListItemProps<TItem extends ListItem> = ListItemProps<TItem> &
isLoading?: boolean;
columns?: SearchColumnType[];
violations?: Record<string, TransactionViolations | undefined> | undefined;
customCardNames?: Record<number, string>;
/** Non-personal and workspace cards for company card display */
nonPersonalAndWorkspaceCards?: CardList;
/** Callback to undelete a transaction */
onUndelete?: (transaction: Transaction) => void;
};
Expand All @@ -437,13 +436,15 @@ type TransactionGroupListItemProps<TItem extends ListItem> = ListItemProps<TItem
columns?: SearchColumnType[];
newTransactionID?: string;
violations?: Record<string, TransactionViolations | undefined> | undefined;
/** Non-personal and workspace cards for company card display */
nonPersonalAndWorkspaceCards?: CardList;
/** Callback to undelete a transaction */
onUndelete?: (transaction: Transaction) => void;
};

type TransactionGroupListExpandedProps<TItem extends ListItem> = Pick<
TransactionGroupListItemProps<TItem>,
'showTooltip' | 'canSelectMultiple' | 'onCheckboxPress' | 'columns' | 'groupBy' | 'accountID' | 'isOffline' | 'violations' | 'onSelectRow' | 'onUndelete'
'showTooltip' | 'canSelectMultiple' | 'onCheckboxPress' | 'columns' | 'groupBy' | 'accountID' | 'isOffline' | 'violations' | 'onSelectRow' | 'nonPersonalAndWorkspaceCards' | 'onUndelete'
> & {
transactions: TransactionListItemType[];
transactionsVisibleLimit: number;
Expand Down
16 changes: 8 additions & 8 deletions src/components/Search/SearchList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import variables from '@styles/variables';
import type {TransactionPreviewData} from '@userActions/Search';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Transaction, TransactionViolations} from '@src/types/onyx';
import type {CardList, Transaction, TransactionViolations} from '@src/types/onyx';
import BaseSearchList from './BaseSearchList';
import type ChatListItem from './ListItem/ChatListItem';
import type ExpenseReportListItem from './ListItem/ExpenseReportListItem';
Expand Down Expand Up @@ -125,12 +125,12 @@ 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>;

/** Selected transactions for determining isSelected state */
selectedTransactions: SelectedTransactions;

/** Non-personal and workspace cards (same drill path as former custom card names for rows) */
nonPersonalAndWorkspaceCards?: CardList;

/** Whether all transactions have been loaded from snapshots in group-by views */
hasLoadedAllTransactions?: boolean;

Expand Down Expand Up @@ -215,7 +215,7 @@ function SearchList({
isMobileSelectionModeEnabled,
newTransactions = [],
violations,
customCardNames,
nonPersonalAndWorkspaceCards,
selectedTransactions,
hasLoadedAllTransactions,
ref,
Expand Down Expand Up @@ -456,7 +456,7 @@ function SearchList({
userBillingFundID={userBillingFundID}
isOffline={isOffline}
violations={violations}
customCardNames={customCardNames}
nonPersonalAndWorkspaceCards={nonPersonalAndWorkspaceCards}
onFocus={onFocus}
newTransactionID={newTransactionID}
onUndelete={handleUndelete}
Expand Down Expand Up @@ -494,7 +494,7 @@ function SearchList({
personalPolicyID,
userBillingGracePeriodEnds,
ownerBillingGracePeriodEnd,
customCardNames,
nonPersonalAndWorkspaceCards,
selectedTransactions,
ListFooterComponent,
handleUndelete,
Expand Down Expand Up @@ -564,7 +564,7 @@ function SearchList({
contentContainerStyle={contentContainerStyle}
newTransactions={newTransactions}
selectedTransactions={selectedTransactions}
customCardNames={customCardNames}
nonPersonalAndWorkspaceCards={nonPersonalAndWorkspaceCards}
/>
<Modal
isVisible={isModalVisible}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@
const [allReportMetadata] = useOnyx(ONYXKEYS.COLLECTION.REPORT_METADATA);
const [visibleColumns] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM, {selector: columnsSelector});
const [customCardNames] = useOnyx(ONYXKEYS.NVP_EXPENSIFY_COMPANY_CARDS_CUSTOM_NAMES);
const [nonPersonalAndWorkspaceCards] = useOnyx(ONYXKEYS.DERIVED.NON_PERSONAL_AND_WORKSPACE_CARD_LIST);
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);

const isExpenseReportType = type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT;
Expand Down Expand Up @@ -1166,7 +1167,7 @@

requestAnimationFrame(() => Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID, backTo})));
},
[

Check warning on line 1170 in src/components/Search/index.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useCallback has an unnecessary dependency: 'currentSearchKey'. Either exclude it or remove the dependency array

Check warning on line 1170 in src/components/Search/index.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useCallback has an unnecessary dependency: 'currentSearchKey'. Either exclude it or remove the dependency array
isMobileSelectionModeEnabled,
markReportIDAsExpense,
toggleTransaction,
Expand Down Expand Up @@ -1681,7 +1682,7 @@
shouldAnimate={type === CONST.SEARCH.DATA_TYPES.EXPENSE}
newTransactions={newTransactions}
hasLoadedAllTransactions={hasLoadedAllTransactions}
customCardNames={customCardNames}
nonPersonalAndWorkspaceCards={nonPersonalAndWorkspaceCards}
/>
</Animated.View>
</SearchScopeProvider>
Expand Down
27 changes: 5 additions & 22 deletions src/components/TransactionItemRow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import useLocalize from '@hooks/useLocalize';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {getCompanyCardDescription} from '@libs/CardUtils';
import {isCategoryMissing} from '@libs/CategoryUtils';
import getBase62ReportID from '@libs/getBase62ReportID';
import {getIOUActionForTransactionID} from '@libs/ReportActionsUtils';
Expand Down Expand Up @@ -52,7 +53,7 @@ import {
import variables from '@styles/variables';
import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import type {PersonalDetails, Policy, Report, ReportAction, TransactionViolation} from '@src/types/onyx';
import type {CardList, PersonalDetails, Policy, Report, ReportAction, TransactionViolation} from '@src/types/onyx';
import type {SearchTransactionAction} from '@src/types/onyx/SearchResults';
import CategoryCell from './DataCells/CategoryCell';
import ChatBubbleCell from './DataCells/ChatBubbleCell';
Expand Down Expand Up @@ -89,9 +90,6 @@ type TransactionWithOptionalSearchFields = TransactionWithOptionalHighlight & {
/** formatted "merchant" value used for displaying and sorting on Reports page */
formattedMerchant?: string;

/** Whether the card feed has been deleted */
isCardFeedDeleted?: boolean;

/** information about whether to show merchant, that is provided on Reports page */
shouldShowMerchant?: boolean;

Expand Down Expand Up @@ -143,10 +141,10 @@ type TransactionItemRowProps = {
onArrowRightPress?: () => void;
isHover?: boolean;
shouldShowArrowRightOnNarrowLayout?: boolean;
customCardNames?: Record<number, string>;
reportActions?: ReportAction[];
checkboxSentryLabel?: string;
isLargeScreenWidth?: boolean;
nonPersonalAndWorkspaceCards?: CardList;
};

const EMPTY_ACTIVE_STYLE: StyleProp<ViewStyle> = [];
Expand Down Expand Up @@ -196,9 +194,9 @@ function TransactionItemRow({
onArrowRightPress,
isHover = false,
shouldShowArrowRightOnNarrowLayout,
customCardNames,
reportActions,
checkboxSentryLabel,
nonPersonalAndWorkspaceCards = {},
isLargeScreenWidth: isLargeScreenWidthProp,
}: TransactionItemRowProps) {
const styles = useThemeStyles();
Expand Down Expand Up @@ -258,23 +256,8 @@ function TransactionItemRow({
}, [transactionItem, translate, report]);

const exchangeRateMessage = getExchangeRate(transactionItem, report?.currency);

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

const cardName = getCompanyCardDescription(translate, transactionItem?.cardName, transactionItem?.cardID, nonPersonalAndWorkspaceCards);
const transactionAttendees = useMemo(() => getAttendees(transactionItem, currentUserPersonalDetails), [transactionItem, currentUserPersonalDetails]);

const shouldShowAttendees = shouldShowAttendeesUtils(CONST.IOU.TYPE.SUBMIT, policy) && transactionAttendees.length > 0;

const totalPerAttendee = useMemo(() => {
Expand Down
Loading
Loading