Skip to content

Add view transactions cta to Expensify card and company cards page #55095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2628,6 +2628,7 @@ const translations = {
planType: 'Plan type',
submitExpense: 'Submit expenses using your workspace chat below:',
defaultCategory: 'Default category',
viewTransactions: 'View transactions',
},
perDiem: {
subtitle: 'Set per diem rates to control daily employee spend. ',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2652,6 +2652,7 @@ const translations = {
planType: 'Tipo de plan',
submitExpense: 'Envíe los gastos utilizando el chat de su espacio de trabajo:',
defaultCategory: 'Categoría predeterminada',
viewTransactions: 'Ver transacciones',
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we confirm this translation ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes.

},
perDiem: {
subtitle: 'Establece las tasas per diem para controlar los gastos diarios de los empleados. ',
Expand Down
14 changes: 11 additions & 3 deletions src/libs/SearchQueryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,14 +615,22 @@ function buildCannedSearchQuery({
type = CONST.SEARCH.DATA_TYPES.EXPENSE,
status = CONST.SEARCH.STATUS.EXPENSE.ALL,
policyID,
cardID,
}: {
type?: SearchDataTypes;
status?: SearchStatus;
policyID?: string;
cardID?: string;
} = {}): SearchQueryString {
const queryString = policyID
? `type:${type} status:${Array.isArray(status) ? status.join(',') : status} policyID:${policyID}`
: `type:${type} status:${Array.isArray(status) ? status.join(',') : status}`;
let queryString = `type:${type} status:${Array.isArray(status) ? status.join(',') : status}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

did you try to mock some transaction data and see if we get the search results ?

Copy link
Member Author

@parasharrajat parasharrajat Jan 15, 2025

Choose a reason for hiding this comment

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

This is the same as before. I haven't tested this part. Did you notice any issues?


if (policyID) {
queryString = `type:${type} status:${Array.isArray(status) ? status.join(',') : status} policyID:${policyID}`;
}

if (cardID) {
queryString = `type:${type} status:${Array.isArray(status) ? status.join(',') : status} expense-type:card card:${cardID}`;
}

// Parse the query to fill all default query fields with values
const normalizedQueryJSON = buildSearchQueryJSON(queryString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@
import usePolicy from '@hooks/usePolicy';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import * as CardUtils from '@libs/CardUtils';

Check failure on line 20 in src/pages/workspace/companyCards/WorkspaceCompanyCardDetailsPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @libs are not allowed. Use named imports instead. Example: import { method } from "@libs/module"
import * as ErrorUtils from '@libs/ErrorUtils';

Check failure on line 21 in src/pages/workspace/companyCards/WorkspaceCompanyCardDetailsPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @libs are not allowed. Use named imports instead. Example: import { method } from "@libs/module"
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';

Check failure on line 24 in src/pages/workspace/companyCards/WorkspaceCompanyCardDetailsPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @libs are not allowed. Use named imports instead. Example: import { method } from "@libs/module"
import * as PolicyUtils from '@libs/PolicyUtils';

Check failure on line 25 in src/pages/workspace/companyCards/WorkspaceCompanyCardDetailsPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @libs are not allowed. Use named imports instead. Example: import { method } from "@libs/module"
import {getConnectedIntegration} from '@libs/PolicyUtils';
import * as SearchQueryUtils from '@libs/SearchQueryUtils';

Check failure on line 27 in src/pages/workspace/companyCards/WorkspaceCompanyCardDetailsPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @libs are not allowed. Use named imports instead. Example: import { method } from "@libs/module"
import Navigation from '@navigation/Navigation';
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import variables from '@styles/variables';
import * as CompanyCards from '@userActions/CompanyCards';

Check failure on line 32 in src/pages/workspace/companyCards/WorkspaceCompanyCardDetailsPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @userActions are not allowed. Use named imports instead. Example: import { action } from "@userActions/module"
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
Expand Down Expand Up @@ -169,6 +170,17 @@
title={card?.scrapeMinDate ? format(parseISO(card.scrapeMinDate), CONST.DATE.FNS_FORMAT_STRING) : ''}
interactive={false}
/>
<MenuItem
icon={Expensicons.MoneySearch}
title={translate('workspace.common.viewTransactions')}
onPress={() => {
Navigation.navigate(
ROUTES.SEARCH_CENTRAL_PANE.getRoute({
query: SearchQueryUtils.buildCannedSearchQuery({type: CONST.SEARCH.DATA_TYPES.EXPENSE, status: CONST.SEARCH.STATUS.EXPENSE.ALL, cardID}),
}),
);
}}
/>
<OfflineWithFeedback
pendingAction={card?.pendingFields?.lastScrape}
errorRowStyles={[styles.ph5, styles.mb3]}
Expand All @@ -180,7 +192,6 @@
disabled={isOffline || card?.isLoadingLastUpdated}
iconFill={theme.success}
title={translate('workspace.moreFeatures.companyCards.updateCard')}
style={styles.mv1}
brickRoadIndicator={card?.errorFields?.lastScrape ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
onPress={updateCard}
/>
Expand All @@ -189,7 +200,7 @@
icon={Expensicons.RemoveMembers}
iconFill={theme.success}
title={translate('workspace.moreFeatures.companyCards.unassignCard')}
style={styles.mv1}
style={styles.mb1}
onPress={() => setIsUnassignModalVisible(true)}
/>
<ConfirmModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
import useNetwork from '@hooks/useNetwork';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import * as CardUtils from '@libs/CardUtils';

Check failure on line 21 in src/pages/workspace/expensifyCard/WorkspaceExpensifyCardDetailsPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @libs are not allowed. Use named imports instead. Example: import { method } from "@libs/module"
import * as CurrencyUtils from '@libs/CurrencyUtils';

Check failure on line 22 in src/pages/workspace/expensifyCard/WorkspaceExpensifyCardDetailsPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @libs are not allowed. Use named imports instead. Example: import { method } from "@libs/module"
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';

Check failure on line 25 in src/pages/workspace/expensifyCard/WorkspaceExpensifyCardDetailsPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @libs are not allowed. Use named imports instead. Example: import { method } from "@libs/module"
import * as PolicyUtils from '@libs/PolicyUtils';

Check failure on line 26 in src/pages/workspace/expensifyCard/WorkspaceExpensifyCardDetailsPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @libs are not allowed. Use named imports instead. Example: import { method } from "@libs/module"
import * as SearchQueryUtils from '@libs/SearchQueryUtils';
import Navigation from '@navigation/Navigation';
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
Expand Down Expand Up @@ -53,7 +54,7 @@
const [cardsList, cardsListResult] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`);

const card = cardsList?.[cardID];
const cardholder = personalDetails?.[card?.accountID ?? -1];
const cardholder = personalDetails?.[card?.accountID ?? CONST.DEFAULT_NUMBER_ID];
const isVirtual = !!card?.nameValuePairs?.isVirtual;
const formattedAvailableSpendAmount = CurrencyUtils.convertToDisplayString(card?.availableSpend);
const formattedLimit = CurrencyUtils.convertToDisplayString(card?.nameValuePairs?.unapprovedExpenseLimit);
Expand Down Expand Up @@ -158,10 +159,21 @@
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_EXPENSIFY_CARD_NAME.getRoute(policyID, cardID))}
/>
</OfflineWithFeedback>
<MenuItem
icon={Expensicons.MoneySearch}
title={translate('workspace.common.viewTransactions')}
onPress={() => {
Navigation.navigate(
ROUTES.SEARCH_CENTRAL_PANE.getRoute({
query: SearchQueryUtils.buildCannedSearchQuery({type: CONST.SEARCH.DATA_TYPES.EXPENSE, status: CONST.SEARCH.STATUS.EXPENSE.ALL, cardID}),
}),
);
}}
/>
<MenuItem
icon={Expensicons.Trashcan}
title={translate('workspace.expensifyCard.deactivate')}
style={styles.mv1}
style={styles.mb1}
onPress={() => (isOffline ? setIsOfflineModalVisible(true) : setIsDeactivateModalVisible(true))}
/>
<ConfirmModal
Expand Down
Loading