From 214551e79f90f46ae4078cc70a0a9f6b9942dbfa Mon Sep 17 00:00:00 2001 From: Sibtain Ali Date: Tue, 24 Jun 2025 03:30:42 +0500 Subject: [PATCH 1/5] add nav options for tracking distance --- .../AttachmentPickerWithMenuItems.tsx | 118 +++++++++++------- .../FloatingActionButtonAndPopover.tsx | 22 +++- src/pages/iou/request/IOURequestStartPage.tsx | 23 ++-- 3 files changed, 109 insertions(+), 54 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx index 2d28bc00512a..928f9f67fd41 100644 --- a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx +++ b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx @@ -13,6 +13,7 @@ import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; import Tooltip from '@components/Tooltip/PopoverAnchorTooltip'; import useEnvironment from '@hooks/useEnvironment'; import useLocalize from '@hooks/useLocalize'; +import usePermissions from '@hooks/usePermissions'; import usePrevious from '@hooks/usePrevious'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; @@ -36,7 +37,7 @@ import type * as OnyxTypes from '@src/types/onyx'; type MoneyRequestOptions = Record< Exclude, - PopoverMenuItem + PopoverMenuItem[] >; type AttachmentPickerWithMenuItemsProps = { @@ -131,6 +132,9 @@ function AttachmentPickerWithMenuItems({ const {isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext); const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`, {canBeMissing: true}); const {isProduction} = useEnvironment(); + const {isBetaEnabled} = usePermissions(); + + const isManualDistanceTrackingEnabled = isBetaEnabled(CONST.BETAS.MANUAL_DISTANCE); const selectOption = useCallback( (onSelected: () => void, shouldRestrictAction: boolean) => { @@ -152,52 +156,80 @@ function AttachmentPickerWithMenuItems({ */ const moneyRequestOptions = useMemo(() => { const options: MoneyRequestOptions = { - [CONST.IOU.TYPE.SPLIT]: { - icon: Expensicons.Transfer, - text: translate('iou.splitExpense'), - shouldCallAfterModalHide: shouldUseNarrowLayout, - onSelected: () => selectOption(() => startMoneyRequest(CONST.IOU.TYPE.SPLIT, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)), true), - }, - [CONST.IOU.TYPE.SUBMIT]: { - icon: getIconForAction(CONST.IOU.TYPE.CREATE), - text: translate('iou.createExpense'), - shouldCallAfterModalHide: shouldUseNarrowLayout, - onSelected: () => selectOption(() => startMoneyRequest(CONST.IOU.TYPE.SUBMIT, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)), true), - }, - [CONST.IOU.TYPE.PAY]: { - icon: getIconForAction(CONST.IOU.TYPE.SEND), - text: translate('iou.paySomeone', {name: getPayeeName(report)}), - shouldCallAfterModalHide: shouldUseNarrowLayout, - onSelected: () => { - if (isDelegateAccessRestricted) { - close(() => { - showDelegateNoAccessModal(); - }); - return; - } - selectOption(() => startMoneyRequest(CONST.IOU.TYPE.PAY, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)), false); + [CONST.IOU.TYPE.SPLIT]: [ + { + icon: Expensicons.Transfer, + text: translate('iou.splitExpense'), + shouldCallAfterModalHide: shouldUseNarrowLayout, + onSelected: () => selectOption(() => startMoneyRequest(CONST.IOU.TYPE.SPLIT, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)), true), }, - }, - [CONST.IOU.TYPE.TRACK]: { - icon: getIconForAction(CONST.IOU.TYPE.CREATE), - text: translate('iou.createExpense'), - shouldCallAfterModalHide: shouldUseNarrowLayout, - onSelected: () => selectOption(() => startMoneyRequest(CONST.IOU.TYPE.TRACK, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)), true), - }, - [CONST.IOU.TYPE.INVOICE]: { - icon: Expensicons.InvoiceGeneric, - text: translate('workspace.invoices.sendInvoice'), - shouldCallAfterModalHide: shouldUseNarrowLayout, - onSelected: () => selectOption(() => startMoneyRequest(CONST.IOU.TYPE.INVOICE, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)), false), - }, + ], + [CONST.IOU.TYPE.SUBMIT]: [ + { + icon: getIconForAction(CONST.IOU.TYPE.CREATE), + text: translate('iou.createExpense'), + shouldCallAfterModalHide: shouldUseNarrowLayout, + onSelected: () => selectOption(() => startMoneyRequest(CONST.IOU.TYPE.SUBMIT, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)), true), + }, + ...(isManualDistanceTrackingEnabled + ? [ + { + icon: Expensicons.Location, + text: translate('quickAction.recordDistance'), + shouldCallAfterModalHide: shouldUseNarrowLayout, + onSelected: () => selectOption(() => null, true), + }, + ] + : []), + ], + [CONST.IOU.TYPE.PAY]: [ + { + icon: getIconForAction(CONST.IOU.TYPE.SEND), + text: translate('iou.paySomeone', {name: getPayeeName(report)}), + shouldCallAfterModalHide: shouldUseNarrowLayout, + onSelected: () => { + if (isDelegateAccessRestricted) { + close(() => { + showDelegateNoAccessModal(); + }); + return; + } + selectOption(() => startMoneyRequest(CONST.IOU.TYPE.PAY, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)), false); + }, + }, + ], + [CONST.IOU.TYPE.TRACK]: [ + { + icon: getIconForAction(CONST.IOU.TYPE.CREATE), + text: translate('iou.createExpense'), + shouldCallAfterModalHide: shouldUseNarrowLayout, + onSelected: () => selectOption(() => startMoneyRequest(CONST.IOU.TYPE.TRACK, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)), true), + }, + ...(isManualDistanceTrackingEnabled + ? [ + { + icon: Expensicons.Location, + text: translate('quickAction.recordDistance'), + shouldCallAfterModalHide: shouldUseNarrowLayout, + onSelected: () => selectOption(() => null, true), + }, + ] + : []), + ], + [CONST.IOU.TYPE.INVOICE]: [ + { + icon: Expensicons.InvoiceGeneric, + text: translate('workspace.invoices.sendInvoice'), + shouldCallAfterModalHide: shouldUseNarrowLayout, + onSelected: () => selectOption(() => startMoneyRequest(CONST.IOU.TYPE.INVOICE, report?.reportID ?? String(CONST.DEFAULT_NUMBER_ID)), false), + }, + ], }; - const moneyRequestOptionsList = temporary_getMoneyRequestOptions(report, policy, reportParticipantIDs ?? []).map((option) => ({ - ...options[option], - })); + const moneyRequestOptionsList = temporary_getMoneyRequestOptions(report, policy, reportParticipantIDs ?? []).map((option) => options[option]); - return moneyRequestOptionsList.filter((item, index, self) => index === self.findIndex((t) => t.text === item.text)); - }, [translate, shouldUseNarrowLayout, report, policy, reportParticipantIDs, selectOption, isDelegateAccessRestricted, showDelegateNoAccessModal]); + return moneyRequestOptionsList.flat().filter((item, index, self) => index === self.findIndex((t) => t.text === item.text)); + }, [translate, shouldUseNarrowLayout, report, policy, reportParticipantIDs, selectOption, isDelegateAccessRestricted, showDelegateNoAccessModal, isManualDistanceTrackingEnabled]); const createReportOption: PopoverMenuItem[] = useMemo(() => { if (!isPolicyExpenseChat(report) || !isPaidGroupPolicy(report) || !isReportOwner(report)) { diff --git a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx index 0409841ea097..9167a47f4380 100644 --- a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx @@ -117,7 +117,8 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT const isFocused = useIsFocused(); const prevIsFocused = usePrevious(isFocused); const {isOffline} = useNetwork(); - const {isBlockedFromSpotnanaTravel} = usePermissions(); + const {isBlockedFromSpotnanaTravel, isBetaEnabled} = usePermissions(); + const isManualDistanceTrackingEnabled = isBetaEnabled(CONST.BETAS.MANUAL_DISTANCE); const [primaryLogin] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => account?.primaryLogin, canBeMissing: true}); const primaryContactMethod = primaryLogin ?? session?.email ?? ''; const [travelSettings] = useOnyx(ONYXKEYS.NVP_TRAVEL_SETTINGS, {canBeMissing: true}); @@ -436,6 +437,25 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT }, ] : []), + ...(isManualDistanceTrackingEnabled + ? [ + { + icon: Expensicons.Location, + text: translate('quickAction.recordDistance'), + shouldCallAfterModalHide: shouldUseNarrowLayout, + onSelected: () => { + interceptAnonymousUser(() => { + if (shouldRedirectToExpensifyClassic) { + setModalVisible(true); + return; + } + // Start the flow to start tracking a distance request + return null; + }); + }, + }, + ] + : []), { icon: Expensicons.ChatBubble, text: translate('sidebarScreen.fabNewChat'), diff --git a/src/pages/iou/request/IOURequestStartPage.tsx b/src/pages/iou/request/IOURequestStartPage.tsx index 37b9c3e61498..268230e7e246 100644 --- a/src/pages/iou/request/IOURequestStartPage.tsx +++ b/src/pages/iou/request/IOURequestStartPage.tsx @@ -150,6 +150,7 @@ function IOURequestStartPage({ }, [headerWithBackBtnContainerElement, tabBarContainerElement, activeTabContainerElement]); const {isBetaEnabled} = usePermissions(); + const manualDistanceTrackingEnabled = isBetaEnabled(CONST.BETAS.MANUAL_DISTANCE); const setTestReceiptAndNavigateRef = useRef<() => void>(); const {shouldShowProductTrainingTooltip, renderProductTrainingTooltip} = useProductTrainingContext( CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP, @@ -234,16 +235,18 @@ function IOURequestStartPage({ )} - - {() => ( - - - - )} - + {!manualDistanceTrackingEnabled && ( + + {() => ( + + + + )} + + )} {!!shouldShowPerDiemOption && ( {() => ( From 50f09df95ea6b20dc5662d95f1aed94757a236c8 Mon Sep 17 00:00:00 2001 From: Sibtain Ali Date: Wed, 25 Jun 2025 02:19:52 +0500 Subject: [PATCH 2/5] add translations --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + .../ReportActionCompose/AttachmentPickerWithMenuItems.tsx | 2 +- src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 4a9f774c760a..d807fc38171d 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1004,6 +1004,7 @@ const translations = { share: 'Share', participants: 'Participants', createExpense: 'Create expense', + trackDistance: 'Track distance', createExpenses: ({expensesNumber}: CreateExpensesParams) => `Create ${expensesNumber} expenses`, addExpense: 'Add expense', chooseRecipient: 'Choose recipient', diff --git a/src/languages/es.ts b/src/languages/es.ts index 340cc97a23c1..9217b9993e90 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -999,6 +999,7 @@ const translations = { share: 'Compartir', participants: 'Participantes', createExpense: 'Crear gasto', + trackDistance: 'Gasto de distancia', createExpenses: ({expensesNumber}: CreateExpensesParams) => `Crear ${expensesNumber} gastos`, paySomeone: ({name}: PaySomeoneParams = {}) => `Pagar a ${name ?? 'alguien'}`, chooseRecipient: 'Elige destinatario', diff --git a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx index ec222e57c5cc..d3596a380a46 100644 --- a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx +++ b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.tsx @@ -209,7 +209,7 @@ function AttachmentPickerWithMenuItems({ ? [ { icon: Expensicons.Location, - text: translate('quickAction.recordDistance'), + text: translate('iou.trackDistance'), shouldCallAfterModalHide: shouldUseNarrowLayout, onSelected: () => selectOption(() => null, true), }, diff --git a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx index ff0b31c24aac..40e4d49c2594 100644 --- a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx @@ -445,7 +445,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT ? [ { icon: Expensicons.Location, - text: translate('quickAction.recordDistance'), + text: translate('iou.trackDistance'), shouldCallAfterModalHide: shouldUseNarrowLayout, onSelected: () => { interceptAnonymousUser(() => { From e17f02a8534b3aa17cf283e403445d8b4a620e73 Mon Sep 17 00:00:00 2001 From: Sibtain Ali Date: Wed, 25 Jun 2025 02:39:00 +0500 Subject: [PATCH 3/5] add all translations --- 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 0058b6c080b1..a25b6d1822ae 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -1019,6 +1019,7 @@ const translations = { share: 'Teilen', participants: 'Teilnehmer', createExpense: 'Ausgabe erstellen', + trackDistance: 'Entfernung verfolgen', createExpenses: ({expensesNumber}: CreateExpensesParams) => `Erstelle ${expensesNumber} Ausgaben`, addExpense: 'Ausgabe hinzufügen', chooseRecipient: 'Empfänger auswählen', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 77fbd26de03e..eb1a3f3e2277 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -1019,6 +1019,7 @@ const translations = { share: 'Partager', participants: 'Participants', createExpense: 'Créer une dépense', + trackDistance: 'Suivre la distance', createExpenses: ({expensesNumber}: CreateExpensesParams) => `Créer ${expensesNumber} dépenses`, addExpense: 'Ajouter une dépense', chooseRecipient: 'Choisir le destinataire', diff --git a/src/languages/it.ts b/src/languages/it.ts index 0ee59802f537..ccd42997958f 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -1015,6 +1015,7 @@ const translations = { share: 'Condividi', participants: 'Partecipanti', createExpense: 'Crea spesa', + trackDistance: 'Traccia distanza', createExpenses: ({expensesNumber}: CreateExpensesParams) => `Crea ${expensesNumber} spese`, addExpense: 'Aggiungi spesa', chooseRecipient: 'Scegli destinatario', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index d626c44f97d6..a3edb2796a5f 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -1018,6 +1018,7 @@ const translations = { share: '共有', participants: '参加者', createExpense: '経費を作成', + trackDistance: '距離を追跡する', createExpenses: ({expensesNumber}: CreateExpensesParams) => `${expensesNumber}件の経費を作成`, addExpense: '経費を追加', chooseRecipient: '受取人を選択', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index df9acabf844a..bb2d4185be33 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -1016,6 +1016,7 @@ const translations = { share: 'Delen', participants: 'Deelnemers', createExpense: 'Uitgave aanmaken', + trackDistance: 'Afstand bijhouden', createExpenses: ({expensesNumber}: CreateExpensesParams) => `Maak ${expensesNumber} uitgaven aan`, addExpense: 'Uitgave toevoegen', chooseRecipient: 'Kies ontvanger', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index 2b516f8af012..9287ce5196d0 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -1014,6 +1014,7 @@ const translations = { share: 'Udostępnij', participants: 'Uczestnicy', createExpense: 'Utwórz wydatek', + trackDistance: 'Śledź odległość', createExpenses: ({expensesNumber}: CreateExpensesParams) => `Utwórz ${expensesNumber} wydatki`, addExpense: 'Dodaj wydatek', chooseRecipient: 'Wybierz odbiorcę', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index 16d087ac08b4..966377669828 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -1016,6 +1016,7 @@ const translations = { share: 'Compartilhar', participants: 'Participantes', createExpense: 'Criar despesa', + trackDistance: 'Rastrear distância', createExpenses: ({expensesNumber}: CreateExpensesParams) => `Criar ${expensesNumber} despesas`, addExpense: 'Adicionar despesa', chooseRecipient: 'Escolher destinatário', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 8397e2a7b431..b53d415358ad 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -1009,6 +1009,7 @@ const translations = { share: '分享', participants: '参与者', createExpense: '创建报销单', + trackDistance: '跟踪距离', createExpenses: ({expensesNumber}: CreateExpensesParams) => `创建${expensesNumber}笔费用`, addExpense: '添加费用', chooseRecipient: '选择收件人', From fdaca106ca217b23219899d4c4b405a01a8ea4ac Mon Sep 17 00:00:00 2001 From: Sibtain Ali Date: Thu, 26 Jun 2025 01:44:08 +0500 Subject: [PATCH 4/5] change order --- .../FloatingActionButtonAndPopover.tsx | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx index d38be40b0c72..e8b2c8cdd62e 100644 --- a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx @@ -402,6 +402,25 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT const menuItems = [ ...expenseMenuItems, + ...(isManualDistanceTrackingEnabled + ? [ + { + icon: Expensicons.Location, + text: translate('iou.trackDistance'), + shouldCallAfterModalHide: shouldUseNarrowLayout, + onSelected: () => { + interceptAnonymousUser(() => { + if (shouldRedirectToExpensifyClassic) { + setModalVisible(true); + return; + } + // Start the flow to start tracking a distance request + return null; + }); + }, + }, + ] + : []), ...(shouldShowCreateReportOption ? [ { @@ -444,25 +463,6 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, isT }, ] : []), - ...(isManualDistanceTrackingEnabled - ? [ - { - icon: Expensicons.Location, - text: translate('iou.trackDistance'), - shouldCallAfterModalHide: shouldUseNarrowLayout, - onSelected: () => { - interceptAnonymousUser(() => { - if (shouldRedirectToExpensifyClassic) { - setModalVisible(true); - return; - } - // Start the flow to start tracking a distance request - return null; - }); - }, - }, - ] - : []), { icon: Expensicons.ChatBubble, text: translate('sidebarScreen.fabNewChat'), From 762c55addff6960be69da2ed0e972e5c6196b7b5 Mon Sep 17 00:00:00 2001 From: Hubert Sosinski Date: Thu, 26 Jun 2025 09:08:13 +0200 Subject: [PATCH 5/5] optimize TotalCell by computing only necessary amount --- .../TransactionItemRow/DataCells/TotalCell.tsx | 10 +++++++--- src/libs/ReportUtils.ts | 14 +++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/components/TransactionItemRow/DataCells/TotalCell.tsx b/src/components/TransactionItemRow/DataCells/TotalCell.tsx index cc5fcb2b6e0e..e574cd0c010b 100644 --- a/src/components/TransactionItemRow/DataCells/TotalCell.tsx +++ b/src/components/TransactionItemRow/DataCells/TotalCell.tsx @@ -1,9 +1,9 @@ -import React from 'react'; +import React, {useMemo} from 'react'; import TextWithTooltip from '@components/TextWithTooltip'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import {convertToDisplayString} from '@libs/CurrencyUtils'; -import {getTransactionDetails} from '@libs/ReportUtils'; +import {getTransactionDetailsAmount} from '@libs/ReportUtils'; import {getCurrency as getTransactionCurrency, isScanning} from '@libs/TransactionUtils'; import type TransactionDataCellProps from './TransactionDataCellProps'; @@ -12,7 +12,11 @@ function TotalCell({shouldShowTooltip, transactionItem}: TransactionDataCellProp const {translate} = useLocalize(); const currency = getTransactionCurrency(transactionItem); - const amount = getTransactionDetails(transactionItem)?.amount; + const amount = useMemo(() => { + return getTransactionDetailsAmount(transactionItem); + // We want this memo to update only when the amount of transactionItem changes + // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps + }, [transactionItem.amount, transactionItem.modifiedAmount]); let amountToDisplay = convertToDisplayString(amount, currency); if (isScanning(transactionItem)) { amountToDisplay = translate('iou.receiptStatusTitle'); diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 7b474d7e222e..bf283f68ff9c 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3951,7 +3951,6 @@ function getMoneyRequestReportName({ * Gets transaction created, amount, currency, comment, and waypoints (for distance expense) * into a flat object. Used for displaying transactions and sending them in API commands */ - function getTransactionDetails( transaction: OnyxInputOrEntry, createdDateFormat: string = CONST.DATE.FNS_FORMAT_STRING, @@ -3984,6 +3983,18 @@ function getTransactionDetails( }; } +/** + * Get the amount of a transaction with proper report context handling. + * This is a lightweight alternative to getTransactionDetails when only the amount is needed. + */ +function getTransactionDetailsAmount(transaction: OnyxInputOrEntry): number | undefined { + if (!transaction) { + return; + } + const report = getReportOrDraftReport(transaction?.reportID); + return getTransactionAmount(transaction, !isEmptyObject(report) && isExpenseReport(report)); +} + function getTransactionCommentObject(transaction: OnyxEntry): Comment { return { ...transaction?.comment, @@ -11517,6 +11528,7 @@ export { isOneTransactionReport, isWorkspaceTaskReport, isWorkspaceThread, + getTransactionDetailsAmount }; export type {