diff --git a/src/pages/workspace/expensifyCard/WorkspaceCardsListLabel.tsx b/src/pages/workspace/expensifyCard/WorkspaceCardsListLabel.tsx index 58e006ca26b1..3f3247ff7f1a 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceCardsListLabel.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceCardsListLabel.tsx @@ -3,6 +3,7 @@ import Icon from '@components/Icon'; import Popover from '@components/Popover'; import {PressableWithFeedback} from '@components/Pressable'; import Text from '@components/Text'; +import TextLink from '@components/TextLink'; import useCurrencyForExpensifyCard from '@hooks/useCurrencyForExpensifyCard'; import {useCurrencyListActions} from '@hooks/useCurrencyList'; @@ -19,7 +20,9 @@ import useWindowDimensions from '@hooks/useWindowDimensions'; import {getCardSettings} from '@libs/CardUtils'; import getClickedTargetLocation from '@libs/getClickedTargetLocation'; import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types'; +import {buildQueryStringFromFilterFormValues} from '@libs/SearchQueryUtils'; +import Navigation from '@navigation/Navigation'; import type {WorkspaceSplitNavigatorParamList} from '@navigation/types'; import variables from '@styles/variables'; @@ -30,6 +33,7 @@ import {navigateToConciergeChat} from '@userActions/Report'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type {StyleProp, ViewStyle} from 'react-native'; @@ -121,6 +125,17 @@ function WorkspaceCardsListLabel({type, value, style}: WorkspaceCardsListLabelPr queueExpensifyCardForBilling(CONST.COUNTRY.US, defaultFundID); }; + const handleViewTransactionsPress = () => { + const fundIDForFeedKey = defaultFundID === CONST.DEFAULT_NUMBER_ID ? undefined : String(defaultFundID); + const feedKey = fundIDForFeedKey ? `${fundIDForFeedKey}_${CONST.EXPENSIFY_CARD.BANK}` : CONST.EXPENSIFY_CARD.BANK; + const query = buildQueryStringFromFilterFormValues({ + type: CONST.SEARCH.DATA_TYPES.EXPENSE, + feed: [feedKey], + withdrawalStatus: [CONST.SEARCH.SETTLEMENT_STATUS.NEVER, CONST.SEARCH.SETTLEMENT_STATUS.PENDING], + }); + Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query})); + }; + return ( @@ -156,6 +171,14 @@ function WorkspaceCardsListLabel({type, value, style}: WorkspaceCardsListLabelPr )} + {isCurrentBalanceType && ( + + {translate('workspace.common.viewTransactions')} + + )} {isSettleDateTextDisplayed && {translate('workspace.expensifyCard.balanceWillBeSettledOn', settlementDate)}} { expect(result).toEqual('type:expense withdrawn:last-month'); }); + test('with Expensify Card current balance view transactions filters', () => { + const feedKey = '21557189_Expensify Card'; + const filterValues: Partial = { + type: CONST.SEARCH.DATA_TYPES.EXPENSE, + feed: [feedKey], + withdrawalStatus: [CONST.SEARCH.SETTLEMENT_STATUS.NEVER, CONST.SEARCH.SETTLEMENT_STATUS.PENDING], + }; + + const result = buildQueryStringFromFilterFormValues(filterValues); + + expect(result).toEqual('type:expense feed:"21557189_Expensify Card" withdrawalStatus:never,pending'); + + const queryJSON = buildSearchQueryJSON(result); + expect(queryJSON?.type).toBe(CONST.SEARCH.DATA_TYPES.EXPENSE); + expect(queryJSON?.flatFilters).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + key: CONST.SEARCH.SYNTAX_FILTER_KEYS.FEED, + filters: [{operator: CONST.SEARCH.SYNTAX_OPERATORS.EQUAL_TO, value: feedKey}], + }), + expect.objectContaining({ + key: CONST.SEARCH.SYNTAX_FILTER_KEYS.WITHDRAWAL_STATUS, + filters: [ + {operator: CONST.SEARCH.SYNTAX_OPERATORS.EQUAL_TO, value: CONST.SEARCH.SETTLEMENT_STATUS.NEVER}, + {operator: CONST.SEARCH.SYNTAX_OPERATORS.EQUAL_TO, value: CONST.SEARCH.SETTLEMENT_STATUS.PENDING}, + ], + }), + ]), + ); + }); + describe('limit option', () => { test('includes limit in query string when provided in form values', () => { const filterValues: Partial = {