Skip to content
Merged
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
23 changes: 23 additions & 0 deletions src/pages/workspace/expensifyCard/WorkspaceCardsListLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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 (
<View style={styles.flex1}>
<View style={styles.flex1}>
Expand Down Expand Up @@ -156,6 +171,14 @@ function WorkspaceCardsListLabel({type, value, style}: WorkspaceCardsListLabelPr
</View>
)}
</View>
{isCurrentBalanceType && (
<TextLink
onPress={handleViewTransactionsPress}
style={styles.mt1}
>
{translate('workspace.common.viewTransactions')}
</TextLink>
)}
</View>
{isSettleDateTextDisplayed && <Text style={[styles.mutedNormalTextLabel, styles.mt1]}>{translate('workspace.expensifyCard.balanceWillBeSettledOn', settlementDate)}</Text>}
<Popover
Expand Down
31 changes: 31 additions & 0 deletions tests/unit/Search/SearchQueryUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,37 @@ describe('SearchQueryUtils', () => {
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<SearchAdvancedFiltersForm> = {
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<SearchAdvancedFiltersForm> = {
Expand Down
Loading