From 0c1d38cc9aff6058b834d0accd228a7a75709226 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Tue, 16 Dec 2025 15:49:34 -0500 Subject: [PATCH 01/17] add new cols for exchange rate --- src/CONST/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CONST/index.ts b/src/CONST/index.ts index f88ade495d2f..d23513ac62a9 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -6695,6 +6695,7 @@ const CONST = { TO: this.TABLE_COLUMNS.TO, CATEGORY: this.TABLE_COLUMNS.CATEGORY, TAG: this.TABLE_COLUMNS.TAG, + EXCHANGE_RATE: this.TABLE_COLUMNS.EXCHANGE_RATE, STATUS: this.TABLE_COLUMNS.STATUS, ACTION: this.TABLE_COLUMNS.ACTION, }, @@ -6801,6 +6802,7 @@ const CONST = { AVATAR: 'avatar', STATUS: 'status', TAX: 'tax', + EXCHANGE_RATE: 'exchangeRate', }, SYNTAX_OPERATORS: { AND: 'and', From d1148be9e1a38c2edf40d7a8e6c42629e45208d9 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Tue, 16 Dec 2025 15:51:44 -0500 Subject: [PATCH 02/17] add exchange rate and en translations --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + src/libs/SearchUIUtils.ts | 3 +++ 3 files changed, 5 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index a157f7108963..ba61a07a99bd 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -681,6 +681,7 @@ const translations = { actionRequired: 'Action required', duplicate: 'Duplicate', duplicated: 'Duplicated', + exchangeRate: 'Exchange rate', }, supportalNoAccess: { title: 'Not so fast', diff --git a/src/languages/es.ts b/src/languages/es.ts index 52c73efba25e..70dbcf35065d 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -377,6 +377,7 @@ const translations: TranslationDeepObject = { actionRequired: 'Acción requerida', duplicate: 'Duplicar', duplicated: 'Duplicado', + exchangeRate: 'Tipo de cambio', }, supportalNoAccess: { title: 'No tan rápido', diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 214d5ef24d56..21951b86b767 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -2227,6 +2227,8 @@ function getSearchColumnTranslationKey(columnId: SearchCustomColumnIds): Transla return 'common.title'; case CONST.SEARCH.TABLE_COLUMNS.STATUS: return 'common.status'; + case CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE: + return 'common.exchangeRate'; } } @@ -2686,6 +2688,7 @@ function getColumnsToShow( [CONST.SEARCH.TABLE_COLUMNS.CATEGORY]: false, [CONST.SEARCH.TABLE_COLUMNS.TAG]: false, [CONST.SEARCH.TABLE_COLUMNS.TAX_AMOUNT]: false, + [CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE]: false, [CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]: true, [CONST.SEARCH.TABLE_COLUMNS.STATUS]: false, [CONST.SEARCH.TABLE_COLUMNS.ACTION]: true, From 2f12abfa398247f38be7c2301ef01c0c01d0899e Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Tue, 16 Dec 2025 15:54:42 -0500 Subject: [PATCH 03/17] apply diff for langs --- src/languages/de.ts | 1 + src/languages/fr.ts | 1 + src/languages/it.ts | 1 + src/languages/ja.ts | 1 + src/languages/nl.ts | 1 + src/languages/pl.ts | 1 + src/languages/pt-BR.ts | 1 + src/languages/zh-hans.ts | 1 + 8 files changed, 8 insertions(+) diff --git a/src/languages/de.ts b/src/languages/de.ts index d3f2b7f6ddbf..c4522c81d5ad 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -691,6 +691,7 @@ const translations: TranslationDeepObject = { actionRequired: 'Aktion erforderlich', duplicate: 'Duplizieren', duplicated: 'Dupliziert', + exchangeRate: 'Wechselkurs', }, supportalNoAccess: { title: 'Nicht so schnell', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 9d7b9a189d68..eb574dcdd11e 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -693,6 +693,7 @@ const translations: TranslationDeepObject = { actionRequired: 'Action requise', duplicate: 'Dupliquer', duplicated: 'Dupliqué', + exchangeRate: 'Taux de change', }, supportalNoAccess: { title: 'Pas si vite', diff --git a/src/languages/it.ts b/src/languages/it.ts index cdecb0981289..51cef681ed8f 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -692,6 +692,7 @@ const translations: TranslationDeepObject = { actionRequired: 'Azione richiesta', duplicate: 'Duplica', duplicated: 'Duplicato', + exchangeRate: 'Tasso di cambio', }, supportalNoAccess: { title: 'Non così in fretta', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index 3e62d11f4448..21da9b58e0b2 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -691,6 +691,7 @@ const translations: TranslationDeepObject = { actionRequired: '対応が必要', duplicate: '複製', duplicated: '重複', + exchangeRate: '為替レート', }, supportalNoAccess: { title: 'ちょっと待ってください', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index eaa4dfc0c1ab..aab94ac67e62 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -692,6 +692,7 @@ const translations: TranslationDeepObject = { actionRequired: 'Actie vereist', duplicate: 'Dupliceren', duplicated: 'Gedupliceerd', + exchangeRate: 'Wisselkoers', }, supportalNoAccess: { title: 'Niet zo snel', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index 7832371a2f2d..a23763cf8ec3 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -692,6 +692,7 @@ const translations: TranslationDeepObject = { actionRequired: 'Wymagane działanie', duplicate: 'Duplikat', duplicated: 'Zduplikowano', + exchangeRate: 'Kurs wymiany', }, supportalNoAccess: { title: 'Nie tak szybko', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index 8e3eec5ab566..a0576659b9f2 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -691,6 +691,7 @@ const translations: TranslationDeepObject = { actionRequired: 'Ação necessária', duplicate: 'Duplicar', duplicated: 'Duplicado', + exchangeRate: 'Taxa de câmbio', }, supportalNoAccess: { title: 'Não tão rápido', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 0ee2a324d7ce..dcb7394b06c0 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -688,6 +688,7 @@ const translations: TranslationDeepObject = { actionRequired: '需要操作', duplicate: '复制', duplicated: '已重复', + exchangeRate: '汇率', }, supportalNoAccess: { title: '先别急', From 7ef020025754b698927d0a48f8bd11772227e153 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Tue, 16 Dec 2025 15:59:32 -0500 Subject: [PATCH 04/17] add header --- .../SelectionListWithSections/SearchTableHeader.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/SelectionListWithSections/SearchTableHeader.tsx b/src/components/SelectionListWithSections/SearchTableHeader.tsx index 250a13725754..6f751fd23d60 100644 --- a/src/components/SelectionListWithSections/SearchTableHeader.tsx +++ b/src/components/SelectionListWithSections/SearchTableHeader.tsx @@ -86,6 +86,10 @@ const getExpenseHeaders = (groupBy?: SearchGroupBy): SearchColumnConfig[] => [ isColumnSortable: false, canBeMissing: true, }, + { + columnName: CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE, + translationKey: 'common.exchangeRate', + }, { columnName: CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT, translationKey: groupBy ? 'common.total' : 'iou.amount', From 4f3d144fdf3a94b13e6e9c87865a4d8ac07036b4 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Tue, 16 Dec 2025 16:15:35 -0500 Subject: [PATCH 05/17] also add text cell here --- .../Search/ExpenseReportListItemRow.tsx | 6 ++++++ .../Search/TextCell.tsx | 21 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/components/SelectionListWithSections/Search/TextCell.tsx diff --git a/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx b/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx index 0eb845a3401b..f54a50f24675 100644 --- a/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx +++ b/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx @@ -18,6 +18,7 @@ import type {Policy} from '@src/types/onyx'; import ActionCell from './ActionCell'; import DateCell from './DateCell'; import StatusCell from './StatusCell'; +import TextCell from './TextCell'; import TitleCell from './TitleCell'; import TotalCell from './TotalCell'; import UserInfoAndActionButtonRow from './UserInfoAndActionButtonRow'; @@ -144,6 +145,11 @@ function ExpenseReportListItemRow({ )} ), + [CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE]: ( + + + + ), [CONST.SEARCH.TABLE_COLUMNS.TOTAL]: ( + ); +} + +export default TextCell; From 201d7b2481f6ec4638e4b01e69bd705bb41a125f Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Tue, 16 Dec 2025 16:21:36 -0500 Subject: [PATCH 06/17] start exchange rate --- .../Search/ExpenseReportListItemRow.tsx | 5 ----- src/components/TransactionItemRow/index.tsx | 11 +++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx b/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx index f54a50f24675..2939ea042d90 100644 --- a/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx +++ b/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx @@ -145,11 +145,6 @@ function ExpenseReportListItemRow({ )} ), - [CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE]: ( - - - - ), [CONST.SEARCH.TABLE_COLUMNS.TOTAL]: ( ({ [CONST.SEARCH.TABLE_COLUMNS.TYPE]: ( @@ -385,6 +391,11 @@ function TransactionItemRow({ /> ), + [CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE]: ( + + + + ), [CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]: ( Date: Tue, 16 Dec 2025 17:00:42 -0500 Subject: [PATCH 07/17] add exchange rate logic --- .../Search/ExpenseReportListItemRow.tsx | 1 - src/components/TransactionItemRow/index.tsx | 44 ++++++++++--------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx b/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx index 2939ea042d90..0eb845a3401b 100644 --- a/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx +++ b/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx @@ -18,7 +18,6 @@ import type {Policy} from '@src/types/onyx'; import ActionCell from './ActionCell'; import DateCell from './DateCell'; import StatusCell from './StatusCell'; -import TextCell from './TextCell'; import TitleCell from './TitleCell'; import TotalCell from './TotalCell'; import UserInfoAndActionButtonRow from './UserInfoAndActionButtonRow'; diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index 3e99cc0fb4ea..c66952077610 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -10,6 +10,7 @@ import type {SearchColumnType, TableColumnSize} from '@components/Search/types'; import ActionCell from '@components/SelectionListWithSections/Search/ActionCell'; import DateCell from '@components/SelectionListWithSections/Search/DateCell'; import StatusCell from '@components/SelectionListWithSections/Search/StatusCell'; +import TextCell from '@components/SelectionListWithSections/Search/TextCell'; import UserInfoCell from '@components/SelectionListWithSections/Search/UserInfoCell'; import Text from '@components/Text'; import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; @@ -211,10 +212,12 @@ function TransactionItemRow({ } }, [transactionItem, translate, report]); - const transactionAmount = getAmount(transactionItem); - const convertedAmount = transactionItem.convertedAmount ?? transactionAmount; - const rate = convertedAmount / transactionAmount; - const exchangeRate = `${rate} ${transactionItem.currency}`; + const fromAmount = getAmount(transactionItem); + const toAmount = transactionItem.convertedAmount ?? fromAmount; + const fromCurrency = transactionItem.modifiedCurrency ?? transactionItem.currency; + const toCurrency = transactionItem.groupCurrency ?? fromCurrency; + const exchangeRate = fromAmount ? Math.abs(toAmount / fromAmount) : 0; + const exchangeRateMessage = `${exchangeRate} ${fromCurrency}/${toCurrency}`; const columnComponent = useMemo( () => ({ @@ -393,7 +396,7 @@ function TransactionItemRow({ ), [CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE]: ( - + ), [CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]: ( @@ -430,27 +433,28 @@ function TransactionItemRow({ }), [ StyleUtils, + transactionItem, + shouldShowTooltip, + shouldUseNarrowLayout, + isSelected, + isDateColumnWide, + areAllOptionalColumnsHidden, createdAt, + isSubmittedColumnWide, report?.submitted, report?.approved, - isActionLoading, - isReportItemChild, - isDateColumnWide, - isSubmittedColumnWide, + report?.policyID, + report?.total, isApprovedColumnWide, - isAmountColumnWide, - isTaxAmountColumnWide, - isInSingleTransactionReport, - isSelected, + isReportItemChild, + onButtonPress, + isActionLoading, merchant, description, - onButtonPress, - shouldShowTooltip, - shouldUseNarrowLayout, - transactionItem, - report?.policyID, - report?.total, - areAllOptionalColumnsHidden, + isInSingleTransactionReport, + exchangeRateMessage, + isAmountColumnWide, + isTaxAmountColumnWide, ], ); const shouldRenderChatBubbleCell = useMemo(() => { From 4674cf027fe95e6045372df6af95ef3014a8b747 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Tue, 16 Dec 2025 17:05:46 -0500 Subject: [PATCH 08/17] conversion cleanup --- src/components/TransactionItemRow/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index c66952077610..2b4c9306f71d 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -24,6 +24,7 @@ import {isSettled} from '@libs/ReportUtils'; import StringUtils from '@libs/StringUtils'; import { getAmount, + getCurrency, getDescription, getMerchant, getCreated as getTransactionCreated, @@ -213,9 +214,11 @@ function TransactionItemRow({ }, [transactionItem, translate, report]); const fromAmount = getAmount(transactionItem); + const fromCurrency = getCurrency(transactionItem); + const toAmount = transactionItem.convertedAmount ?? fromAmount; - const fromCurrency = transactionItem.modifiedCurrency ?? transactionItem.currency; const toCurrency = transactionItem.groupCurrency ?? fromCurrency; + const exchangeRate = fromAmount ? Math.abs(toAmount / fromAmount) : 0; const exchangeRateMessage = `${exchangeRate} ${fromCurrency}/${toCurrency}`; From dfd4688dddd71b2192593324115129b883c39d7c Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Tue, 16 Dec 2025 17:14:02 -0500 Subject: [PATCH 09/17] abstract the method --- src/components/TransactionItemRow/index.tsx | 17 ++++------------- src/libs/TransactionUtils/index.ts | 16 ++++++++++++++++ src/styles/utils/index.ts | 1 + 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index 2b4c9306f71d..336e5e6f8fce 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -23,9 +23,8 @@ import {isCategoryMissing} from '@libs/CategoryUtils'; import {isSettled} from '@libs/ReportUtils'; import StringUtils from '@libs/StringUtils'; import { - getAmount, - getCurrency, getDescription, + getExchangeRate, getMerchant, getCreated as getTransactionCreated, hasMissingSmartscanFields, @@ -213,14 +212,7 @@ function TransactionItemRow({ } }, [transactionItem, translate, report]); - const fromAmount = getAmount(transactionItem); - const fromCurrency = getCurrency(transactionItem); - - const toAmount = transactionItem.convertedAmount ?? fromAmount; - const toCurrency = transactionItem.groupCurrency ?? fromCurrency; - - const exchangeRate = fromAmount ? Math.abs(toAmount / fromAmount) : 0; - const exchangeRateMessage = `${exchangeRate} ${fromCurrency}/${toCurrency}`; + const exchangeRate = getExchangeRate(transactionItem); const columnComponent = useMemo( () => ({ @@ -398,8 +390,8 @@ function TransactionItemRow({ ), [CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE]: ( - - + + ), [CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]: ( @@ -455,7 +447,6 @@ function TransactionItemRow({ merchant, description, isInSingleTransactionReport, - exchangeRateMessage, isAmountColumnWide, isTaxAmountColumnWide, ], diff --git a/src/libs/TransactionUtils/index.ts b/src/libs/TransactionUtils/index.ts index 5abcda9ad946..22eae05651bb 100644 --- a/src/libs/TransactionUtils/index.ts +++ b/src/libs/TransactionUtils/index.ts @@ -9,6 +9,7 @@ import type {ValueOf} from 'type-fest'; import type {Coordinate} from '@components/MapView/MapViewTypes'; import utils from '@components/MapView/utils'; import type {UnreportedExpenseListItemType} from '@components/SelectionListWithSections/types'; +import {TransactionWithOptionalSearchFields} from '@components/TransactionItemRow'; import {getPolicyTagsData} from '@libs/actions/Policy/Tag'; import type {MergeDuplicatesParams} from '@libs/API/parameters'; import {getCategoryDefaultTaxRate} from '@libs/CategoryUtils'; @@ -765,6 +766,20 @@ function getAmount(transaction: OnyxInputOrEntry, isFromExpenseRepo return amount ? -amount : 0; } +/** + * Returns the exchange rate for a transaction + */ +function getExchangeRate(transaction: TransactionWithOptionalSearchFields) { + const fromAmount = getAmount(transaction); + const fromCurrency = getCurrency(transaction); + + const toAmount = transaction.convertedAmount ?? fromAmount; + const toCurrency = transaction.groupCurrency ?? fromCurrency; + + const exchangeRate = fromAmount ? Math.abs(toAmount / fromAmount) : 0; + return `${exchangeRate} ${fromCurrency}/${toCurrency}`; +} + /** * Return the tax amount field from the transaction. */ @@ -2266,6 +2281,7 @@ export { isManualRequest, isScanRequest, getAmount, + getExchangeRate, getAttendees, getTaxAmount, getTaxCode, diff --git a/src/styles/utils/index.ts b/src/styles/utils/index.ts index be6adc1f30db..9465129cf53e 100644 --- a/src/styles/utils/index.ts +++ b/src/styles/utils/index.ts @@ -1777,6 +1777,7 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({ case CONST.SEARCH.TABLE_COLUMNS.TITLE: case CONST.SEARCH.TABLE_COLUMNS.DESCRIPTION: case CONST.SEARCH.TABLE_COLUMNS.IN: + case CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE: default: columnWidth = styles.flex1; } From 8bc55103aaf52cecd9a4e9bf0b35977b39b03ef8 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Tue, 16 Dec 2025 17:41:55 -0500 Subject: [PATCH 10/17] add sorting for exchange rate --- src/components/TransactionItemRow/index.tsx | 1 + src/libs/SearchUIUtils.ts | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index 336e5e6f8fce..e75ac8c0b5eb 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -447,6 +447,7 @@ function TransactionItemRow({ merchant, description, isInSingleTransactionReport, + exchangeRate, isAmountColumnWide, isTaxAmountColumnWide, ], diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 21951b86b767..4ca0a5b300ff 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -116,6 +116,7 @@ import {getIOUPayerAndReceiver} from './TransactionPreviewUtils'; import { getCategory, getDescription, + getExchangeRate, getTag, getTaxAmount, getAmount as getTransactionAmount, @@ -2014,6 +2015,14 @@ function getSortedTransactionData( }); } + if (sortBy === CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE) { + return data.sort((a, b) => { + const aExchangeRate = getExchangeRate(a); + const bExchangeRate = getExchangeRate(b); + return compareValues(aExchangeRate, bExchangeRate, sortOrder, sortBy, localeCompare, true); + }); + } + if (!sortingProperty) { return data; } From c9ef9fa8e00869ef2f069f566bc4f73cdd7c715f Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Tue, 16 Dec 2025 17:50:04 -0500 Subject: [PATCH 11/17] fix lint --- src/libs/TransactionUtils/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/TransactionUtils/index.ts b/src/libs/TransactionUtils/index.ts index 22eae05651bb..599136e0ef7b 100644 --- a/src/libs/TransactionUtils/index.ts +++ b/src/libs/TransactionUtils/index.ts @@ -9,7 +9,7 @@ import type {ValueOf} from 'type-fest'; import type {Coordinate} from '@components/MapView/MapViewTypes'; import utils from '@components/MapView/utils'; import type {UnreportedExpenseListItemType} from '@components/SelectionListWithSections/types'; -import {TransactionWithOptionalSearchFields} from '@components/TransactionItemRow'; +import type {TransactionWithOptionalSearchFields} from '@components/TransactionItemRow'; import {getPolicyTagsData} from '@libs/actions/Policy/Tag'; import type {MergeDuplicatesParams} from '@libs/API/parameters'; import {getCategoryDefaultTaxRate} from '@libs/CategoryUtils'; From 641ef51ec879c41db046e85a9a1e7597db677a99 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Wed, 17 Dec 2025 18:16:31 -0500 Subject: [PATCH 12/17] add new groupExchangeRate --- src/components/Search/index.tsx | 4 ++++ src/components/Search/types.ts | 3 +++ src/libs/DebugUtils.ts | 2 ++ src/libs/TransactionUtils/index.ts | 16 ---------------- src/types/onyx/SearchResults.ts | 3 +++ src/types/onyx/Transaction.ts | 3 +++ 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 91241b5d3404..4c0c21290cb5 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -126,6 +126,7 @@ function mapTransactionItemToSelectedEntry( ), action: item.action, groupCurrency: item.groupCurrency, + groupExchangeRate: item.groupExchangeRate, reportID: item.reportID, policyID: item.report?.policyID, amount: item.modifiedAmount ?? item.amount, @@ -223,6 +224,7 @@ function prepareTransactionsList( amount: Math.abs(item.modifiedAmount || item.amount), groupAmount: item.groupAmount, groupCurrency: item.groupCurrency, + groupExchangeRate: item.groupExchangeRate, currency: item.currency, isFromOneTransactionReport: isOneTransactionReport(item.report), ownerAccountID: item.reportAction?.actorAccountID, @@ -553,6 +555,7 @@ function Search({ amount: transactionItem.modifiedAmount ?? transactionItem.amount, groupAmount: transactionItem.groupAmount, groupCurrency: transactionItem.groupCurrency, + groupExchangeRate: transactionItem.groupExchangeRate, currency: transactionItem.currency, ownerAccountID: transactionItem.reportAction?.actorAccountID, }; @@ -605,6 +608,7 @@ function Search({ amount: transactionItem.modifiedAmount ?? transactionItem.amount, groupAmount: transactionItem.groupAmount, groupCurrency: transactionItem.groupCurrency, + groupExchangeRate: transactionItem.groupExchangeRate, currency: transactionItem.currency, ownerAccountID: transactionItem.reportAction?.actorAccountID, }; diff --git a/src/components/Search/types.ts b/src/components/Search/types.ts index e0997ba00990..74ad8c14fc44 100644 --- a/src/components/Search/types.ts +++ b/src/components/Search/types.ts @@ -56,6 +56,9 @@ type SelectedTransactionInfo = { /** The group currency if the transaction is grouped. Defaults to the active policy currency if group has no target currency */ groupCurrency?: string; + /** The exchange rate of the transaction if the transaction is grouped. Defaults to the exchange rate against the active policy currency if group has no target currency */ + groupExchangeRate?: number; + /** Whether it is the only expense of the parent expense report */ isFromOneTransactionReport?: boolean; diff --git a/src/libs/DebugUtils.ts b/src/libs/DebugUtils.ts index 2d5ebd0c8ccc..20af4dc2c5d1 100644 --- a/src/libs/DebugUtils.ts +++ b/src/libs/DebugUtils.ts @@ -986,6 +986,7 @@ function validateTransactionDraftProperty(key: keyof Transaction, value: string) case 'originalAmount': case 'convertedAmount': case 'groupAmount': + case 'groupExchangeRate': return validateNumber(value); case 'iouRequestType': return validateConstantEnum(value, CONST.IOU.REQUEST_TYPE); @@ -1107,6 +1108,7 @@ function validateTransactionDraftProperty(key: keyof Transaction, value: string) taxValue: CONST.RED_BRICK_ROAD_PENDING_ACTION, groupAmount: CONST.RED_BRICK_ROAD_PENDING_ACTION, groupCurrency: CONST.RED_BRICK_ROAD_PENDING_ACTION, + groupExchangeRate: CONST.RED_BRICK_ROAD_PENDING_ACTION, }, 'string', ); diff --git a/src/libs/TransactionUtils/index.ts b/src/libs/TransactionUtils/index.ts index 38bd689dfc22..e6b602c319ab 100644 --- a/src/libs/TransactionUtils/index.ts +++ b/src/libs/TransactionUtils/index.ts @@ -9,7 +9,6 @@ import type {ValueOf} from 'type-fest'; import type {Coordinate} from '@components/MapView/MapViewTypes'; import utils from '@components/MapView/utils'; import type {UnreportedExpenseListItemType} from '@components/SelectionListWithSections/types'; -import type {TransactionWithOptionalSearchFields} from '@components/TransactionItemRow'; import {getPolicyTagsData} from '@libs/actions/Policy/Tag'; import type {MergeDuplicatesParams} from '@libs/API/parameters'; import {getCategoryDefaultTaxRate} from '@libs/CategoryUtils'; @@ -766,20 +765,6 @@ function getAmount(transaction: OnyxInputOrEntry, isFromExpenseRepo return amount ? -amount : 0; } -/** - * Returns the exchange rate for a transaction - */ -function getExchangeRate(transaction: TransactionWithOptionalSearchFields) { - const fromAmount = getAmount(transaction); - const fromCurrency = getCurrency(transaction); - - const toAmount = transaction.convertedAmount ?? fromAmount; - const toCurrency = transaction.groupCurrency ?? fromCurrency; - - const exchangeRate = fromAmount ? Math.abs(toAmount / fromAmount) : 0; - return `${exchangeRate} ${fromCurrency}/${toCurrency}`; -} - /** * Return the tax amount field from the transaction. */ @@ -2286,7 +2271,6 @@ export { isManualRequest, isScanRequest, getAmount, - getExchangeRate, getAttendees, getTaxAmount, getTaxCode, diff --git a/src/types/onyx/SearchResults.ts b/src/types/onyx/SearchResults.ts index b4c1b566c49c..03817227b3c4 100644 --- a/src/types/onyx/SearchResults.ts +++ b/src/types/onyx/SearchResults.ts @@ -170,6 +170,9 @@ type SearchTransaction = { /** The group currency if the transaction is grouped. Defaults to the active policy currency if group has no target currency */ groupCurrency?: string; + /** The exchange rate of the transaction if the transaction is grouped. Defaults to the exchange rate against the active policy currency if group has no target currency */ + groupExchangeRate?: number; + /** Reimbursable status of the transaction */ reimbursable?: boolean; diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index c844f47f60b3..97cb5a412b9e 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -445,6 +445,9 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< /** The group currency if the transaction is grouped. Defaults to the active policy currency if group has no target currency */ groupCurrency?: string; + /** The exchange rate of the transaction if the transaction is grouped. Defaults to the exchange rate against the active policy currency if group has no target currency */ + groupExchangeRate?: number; + /** Used during the creation flow before the transaction is saved to the server */ iouRequestType?: IOURequestType; From 7ddd2652fc05fe9f86d8b099ed2dee4c53dcf58b Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Wed, 17 Dec 2025 18:20:13 -0500 Subject: [PATCH 13/17] add a message for exchange rate --- src/components/TransactionItemRow/index.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index 16a890fbdfdf..8b749686146d 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -26,8 +26,8 @@ import getBase62ReportID from '@libs/getBase62ReportID'; import {isExpenseReport, isSettled} from '@libs/ReportUtils'; import StringUtils from '@libs/StringUtils'; import { + getCurrency, getDescription, - getExchangeRate, getMerchant, getOriginalAmount, getOriginalCurrency, @@ -238,7 +238,9 @@ function TransactionItemRow({ } }, [transactionItem, translate, report]); - const exchangeRate = getExchangeRate(transactionItem); + const fromCurrency = getCurrency(transactionItem); + const toCurrency = transactionItem.groupCurrency ?? fromCurrency; + const exchangeRateMessage = transactionItem.groupExchangeRate ? `${transactionItem.groupExchangeRate} ${fromCurrency}/${toCurrency}` : ''; const columnComponent = useMemo( () => ({ @@ -453,7 +455,7 @@ function TransactionItemRow({ ), [CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE]: ( - + ), [CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT]: ( @@ -534,7 +536,6 @@ function TransactionItemRow({ ), }), [ - translate, StyleUtils, transactionItem, shouldShowTooltip, @@ -550,17 +551,18 @@ function TransactionItemRow({ report?.total, isApprovedColumnWide, isPostedColumnWide, + translate, isReportItemChild, onButtonPress, isActionLoading, merchant, description, isInSingleTransactionReport, - exchangeRate, + exchangeRateMessage, isAmountColumnWide, + formattedTaxRate, isTaxAmountColumnWide, isLargeScreenWidth, - formattedTaxRate, ], ); const shouldRenderChatBubbleCell = useMemo(() => { From 92b49d20d87593732e7f7e2a4598618db1472aae Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Wed, 17 Dec 2025 18:23:06 -0500 Subject: [PATCH 14/17] create helper so sorting works --- src/components/TransactionItemRow/index.tsx | 6 ++---- src/libs/TransactionUtils/index.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index 8b749686146d..28752bf9eec7 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -26,8 +26,8 @@ import getBase62ReportID from '@libs/getBase62ReportID'; import {isExpenseReport, isSettled} from '@libs/ReportUtils'; import StringUtils from '@libs/StringUtils'; import { - getCurrency, getDescription, + getExchangeRate, getMerchant, getOriginalAmount, getOriginalCurrency, @@ -238,9 +238,7 @@ function TransactionItemRow({ } }, [transactionItem, translate, report]); - const fromCurrency = getCurrency(transactionItem); - const toCurrency = transactionItem.groupCurrency ?? fromCurrency; - const exchangeRateMessage = transactionItem.groupExchangeRate ? `${transactionItem.groupExchangeRate} ${fromCurrency}/${toCurrency}` : ''; + const exchangeRateMessage = getExchangeRate(transactionItem); const columnComponent = useMemo( () => ({ diff --git a/src/libs/TransactionUtils/index.ts b/src/libs/TransactionUtils/index.ts index e6b602c319ab..f60f6b2e9e09 100644 --- a/src/libs/TransactionUtils/index.ts +++ b/src/libs/TransactionUtils/index.ts @@ -9,6 +9,7 @@ import type {ValueOf} from 'type-fest'; import type {Coordinate} from '@components/MapView/MapViewTypes'; import utils from '@components/MapView/utils'; import type {UnreportedExpenseListItemType} from '@components/SelectionListWithSections/types'; +import {TransactionWithOptionalSearchFields} from '@components/TransactionItemRow'; import {getPolicyTagsData} from '@libs/actions/Policy/Tag'; import type {MergeDuplicatesParams} from '@libs/API/parameters'; import {getCategoryDefaultTaxRate} from '@libs/CategoryUtils'; @@ -50,6 +51,7 @@ import CONST from '@src/CONST'; import type {IOUType} from '@src/CONST'; import IntlStore from '@src/languages/IntlStore'; import ONYXKEYS from '@src/ONYXKEYS'; +import {transactionWithOptionalSearchFields} from '@src/stories/objects/Transaction'; import type { CardList, OnyxInputOrEntry, @@ -1037,6 +1039,15 @@ function getTagArrayFromName(tagName: string): string[] { return newMatches; } +/** + * Returns the exchange rate for a transaction, based on its group + */ +function getExchangeRate(transaction: TransactionWithOptionalSearchFields) { + const fromCurrency = getCurrency(transaction); + const toCurrency = transaction.groupCurrency ?? fromCurrency; + return transaction.groupExchangeRate ? `${transactionWithOptionalSearchFields.groupExchangeRate} ${fromCurrency}/${toCurrency}` : ''; +} + /** * Return the tag from the transaction. When the tagIndex is passed, return the tag based on the index. * This "tag" field has no "modified" complement. @@ -2372,6 +2383,7 @@ export { mergeProhibitedViolations, getOriginalAttendees, getReportOwnerAsAttendee, + getExchangeRate, }; export type {TransactionChanges}; From 5ace60b7f83e44b7d5421c4a858ce760a0453b55 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Wed, 17 Dec 2025 18:42:21 -0500 Subject: [PATCH 15/17] handle more exchange rate data --- src/libs/TransactionUtils/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libs/TransactionUtils/index.ts b/src/libs/TransactionUtils/index.ts index f60f6b2e9e09..0961c310d1f9 100644 --- a/src/libs/TransactionUtils/index.ts +++ b/src/libs/TransactionUtils/index.ts @@ -1045,7 +1045,16 @@ function getTagArrayFromName(tagName: string): string[] { function getExchangeRate(transaction: TransactionWithOptionalSearchFields) { const fromCurrency = getCurrency(transaction); const toCurrency = transaction.groupCurrency ?? fromCurrency; - return transaction.groupExchangeRate ? `${transactionWithOptionalSearchFields.groupExchangeRate} ${fromCurrency}/${toCurrency}` : ''; + + if (!transaction.groupExchangeRate) { + return ''; + } + + if (Number(transaction.groupExchangeRate) === 1) { + return ''; + } + + return transaction.groupExchangeRate ? `${transaction.groupExchangeRate} ${fromCurrency}/${toCurrency}` : ''; } /** From 6fb73c805a3e35caca8dc4f33be695d020b62492 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Wed, 17 Dec 2025 18:47:17 -0500 Subject: [PATCH 16/17] fix tests --- tests/unit/Search/SearchUIUtilsTest.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index 0b5367f7e37d..5ef9d8d7e846 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -2775,6 +2775,7 @@ describe('SearchUIUtils', () => { [CONST.SEARCH.TABLE_COLUMNS.NON_REIMBURSABLE_TOTAL]: false, [CONST.SEARCH.TABLE_COLUMNS.BASE_62_REPORT_ID]: false, [CONST.SEARCH.TABLE_COLUMNS.REPORT_ID]: false, + [CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE]: false, }); }); @@ -2799,6 +2800,7 @@ describe('SearchUIUtils', () => { [CONST.SEARCH.TABLE_COLUMNS.NON_REIMBURSABLE_TOTAL]: false, [CONST.SEARCH.TABLE_COLUMNS.BASE_62_REPORT_ID]: false, [CONST.SEARCH.TABLE_COLUMNS.REPORT_ID]: false, + [CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE]: false, }); }); From 2f10a4a5a36c0fe14c5ce0ad0036b5f8e6aa6365 Mon Sep 17 00:00:00 2001 From: Jack Senyitko Date: Wed, 17 Dec 2025 18:53:29 -0500 Subject: [PATCH 17/17] fix eslint --- src/libs/TransactionUtils/index.ts | 3 +-- tests/unit/Search/SearchUIUtilsTest.ts | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/libs/TransactionUtils/index.ts b/src/libs/TransactionUtils/index.ts index 0961c310d1f9..3015b7d3778d 100644 --- a/src/libs/TransactionUtils/index.ts +++ b/src/libs/TransactionUtils/index.ts @@ -9,7 +9,7 @@ import type {ValueOf} from 'type-fest'; import type {Coordinate} from '@components/MapView/MapViewTypes'; import utils from '@components/MapView/utils'; import type {UnreportedExpenseListItemType} from '@components/SelectionListWithSections/types'; -import {TransactionWithOptionalSearchFields} from '@components/TransactionItemRow'; +import type {TransactionWithOptionalSearchFields} from '@components/TransactionItemRow'; import {getPolicyTagsData} from '@libs/actions/Policy/Tag'; import type {MergeDuplicatesParams} from '@libs/API/parameters'; import {getCategoryDefaultTaxRate} from '@libs/CategoryUtils'; @@ -51,7 +51,6 @@ import CONST from '@src/CONST'; import type {IOUType} from '@src/CONST'; import IntlStore from '@src/languages/IntlStore'; import ONYXKEYS from '@src/ONYXKEYS'; -import {transactionWithOptionalSearchFields} from '@src/stories/objects/Transaction'; import type { CardList, OnyxInputOrEntry, diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index 5ef9d8d7e846..0b5367f7e37d 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -2775,7 +2775,6 @@ describe('SearchUIUtils', () => { [CONST.SEARCH.TABLE_COLUMNS.NON_REIMBURSABLE_TOTAL]: false, [CONST.SEARCH.TABLE_COLUMNS.BASE_62_REPORT_ID]: false, [CONST.SEARCH.TABLE_COLUMNS.REPORT_ID]: false, - [CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE]: false, }); }); @@ -2800,7 +2799,6 @@ describe('SearchUIUtils', () => { [CONST.SEARCH.TABLE_COLUMNS.NON_REIMBURSABLE_TOTAL]: false, [CONST.SEARCH.TABLE_COLUMNS.BASE_62_REPORT_ID]: false, [CONST.SEARCH.TABLE_COLUMNS.REPORT_ID]: false, - [CONST.SEARCH.TABLE_COLUMNS.EXCHANGE_RATE]: false, }); });