From e3e6bec3c21abc934ad2d194c76697b8223bfd96 Mon Sep 17 00:00:00 2001 From: mkzie2 Date: Mon, 10 Mar 2025 17:54:21 +0700 Subject: [PATCH 1/3] fix: distance receipt not show in split details --- src/components/MoneyRequestConfirmationListFooter.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/MoneyRequestConfirmationListFooter.tsx b/src/components/MoneyRequestConfirmationListFooter.tsx index 780571d9b4a8..608b29dbe2c1 100644 --- a/src/components/MoneyRequestConfirmationListFooter.tsx +++ b/src/components/MoneyRequestConfirmationListFooter.tsx @@ -19,7 +19,7 @@ import type {ThumbnailAndImageURI} from '@libs/ReceiptUtils'; import {getThumbnailAndImageURIs} from '@libs/ReceiptUtils'; import {getDefaultWorkspaceAvatar} from '@libs/ReportUtils'; import {hasEnabledTags} from '@libs/TagsOptionsListUtils'; -import {getTagForDisplay, getTaxAmount, getTaxName, isAmountMissing, isCreatedMissing, shouldShowAttendees as shouldShowAttendeesTransactionUtils} from '@libs/TransactionUtils'; +import {getTagForDisplay, getTaxAmount, getTaxName, isAmountMissing, isCreatedMissing, isFetchingWaypointsFromServer, shouldShowAttendees as shouldShowAttendeesTransactionUtils} from '@libs/TransactionUtils'; import tryResolveUrlFromApiRoot from '@libs/tryResolveUrlFromApiRoot'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; import CONST from '@src/CONST'; @@ -41,6 +41,7 @@ import ReceiptEmptyState from './ReceiptEmptyState'; import ReceiptImage from './ReceiptImage'; import {ShowContextMenuContext} from './ShowContextMenuContext'; import ShowMoreButton from './ShowMoreButton'; +import { isEmptyObject } from '@src/types/utils/EmptyObject'; type MoneyRequestConfirmationListFooterProps = { /** The action to perform */ @@ -239,6 +240,10 @@ function MoneyRequestConfirmationListFooter({ const isMultilevelTags = useMemo(() => isMultiLevelTagsPolicyUtils(policyTags), [policyTags]); const shouldShowAttendees = useMemo(() => shouldShowAttendeesTransactionUtils(iouType, policy), [iouType, policy]); + const hasPendingWaypoints = transaction && isFetchingWaypointsFromServer(transaction); + const hasErrors = !isEmptyObject(transaction?.errors) || !isEmptyObject(transaction?.errorFields?.route) || !isEmptyObject(transaction?.errorFields?.waypoints); + const showMapAsImage = isDistanceRequest && !!(hasErrors || hasPendingWaypoints || iouType !== CONST.IOU.TYPE.SPLIT || !isReadOnly); + const senderWorkspace = useMemo(() => { const senderWorkspaceParticipant = selectedParticipants.find((participant) => participant.isSender); return allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${senderWorkspaceParticipant?.policyID}`]; @@ -773,7 +778,7 @@ function MoneyRequestConfirmationListFooter({ disabled={didConfirm} /> )} - {isDistanceRequest && ( + {showMapAsImage && ( @@ -818,7 +823,7 @@ function MoneyRequestConfirmationListFooter({ )} - {!isDistanceRequest && + {!showMapAsImage && // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing (receiptImage || receiptThumbnail ? receiptThumbnailContent From 53e877c204a8b0045baed705d84fc3c06e1cebbc Mon Sep 17 00:00:00 2001 From: mkzie2 Date: Mon, 10 Mar 2025 18:00:18 +0700 Subject: [PATCH 2/3] fix lint --- .../MoneyRequestConfirmationListFooter.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/MoneyRequestConfirmationListFooter.tsx b/src/components/MoneyRequestConfirmationListFooter.tsx index 608b29dbe2c1..349a2697b078 100644 --- a/src/components/MoneyRequestConfirmationListFooter.tsx +++ b/src/components/MoneyRequestConfirmationListFooter.tsx @@ -19,7 +19,15 @@ import type {ThumbnailAndImageURI} from '@libs/ReceiptUtils'; import {getThumbnailAndImageURIs} from '@libs/ReceiptUtils'; import {getDefaultWorkspaceAvatar} from '@libs/ReportUtils'; import {hasEnabledTags} from '@libs/TagsOptionsListUtils'; -import {getTagForDisplay, getTaxAmount, getTaxName, isAmountMissing, isCreatedMissing, isFetchingWaypointsFromServer, shouldShowAttendees as shouldShowAttendeesTransactionUtils} from '@libs/TransactionUtils'; +import { + getTagForDisplay, + getTaxAmount, + getTaxName, + isAmountMissing, + isCreatedMissing, + isFetchingWaypointsFromServer, + shouldShowAttendees as shouldShowAttendeesTransactionUtils, +} from '@libs/TransactionUtils'; import tryResolveUrlFromApiRoot from '@libs/tryResolveUrlFromApiRoot'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; import CONST from '@src/CONST'; @@ -29,6 +37,7 @@ import ROUTES from '@src/ROUTES'; import type * as OnyxTypes from '@src/types/onyx'; import type {Attendee, Participant} from '@src/types/onyx/IOU'; import type {Unit} from '@src/types/onyx/Policy'; +import {isEmptyObject} from '@src/types/utils/EmptyObject'; import Badge from './Badge'; import ConfirmedRoute from './ConfirmedRoute'; import MentionReportContext from './HTMLEngineProvider/HTMLRenderers/MentionReportRenderer/MentionReportContext'; @@ -41,7 +50,6 @@ import ReceiptEmptyState from './ReceiptEmptyState'; import ReceiptImage from './ReceiptImage'; import {ShowContextMenuContext} from './ShowContextMenuContext'; import ShowMoreButton from './ShowMoreButton'; -import { isEmptyObject } from '@src/types/utils/EmptyObject'; type MoneyRequestConfirmationListFooterProps = { /** The action to perform */ @@ -242,6 +250,7 @@ function MoneyRequestConfirmationListFooter({ const hasPendingWaypoints = transaction && isFetchingWaypointsFromServer(transaction); const hasErrors = !isEmptyObject(transaction?.errors) || !isEmptyObject(transaction?.errorFields?.route) || !isEmptyObject(transaction?.errorFields?.waypoints); + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const showMapAsImage = isDistanceRequest && !!(hasErrors || hasPendingWaypoints || iouType !== CONST.IOU.TYPE.SPLIT || !isReadOnly); const senderWorkspace = useMemo(() => { From 703067ba409e7c32d0b39108b6fdfbec8fe8987a Mon Sep 17 00:00:00 2001 From: mkzie2 Date: Thu, 13 Mar 2025 00:20:25 +0700 Subject: [PATCH 3/3] rename showMapAsImage --- src/components/MoneyRequestConfirmationListFooter.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/MoneyRequestConfirmationListFooter.tsx b/src/components/MoneyRequestConfirmationListFooter.tsx index 349a2697b078..e8b23b164b9e 100644 --- a/src/components/MoneyRequestConfirmationListFooter.tsx +++ b/src/components/MoneyRequestConfirmationListFooter.tsx @@ -251,7 +251,7 @@ function MoneyRequestConfirmationListFooter({ const hasPendingWaypoints = transaction && isFetchingWaypointsFromServer(transaction); const hasErrors = !isEmptyObject(transaction?.errors) || !isEmptyObject(transaction?.errorFields?.route) || !isEmptyObject(transaction?.errorFields?.waypoints); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const showMapAsImage = isDistanceRequest && !!(hasErrors || hasPendingWaypoints || iouType !== CONST.IOU.TYPE.SPLIT || !isReadOnly); + const shouldShowMap = isDistanceRequest && !!(hasErrors || hasPendingWaypoints || iouType !== CONST.IOU.TYPE.SPLIT || !isReadOnly); const senderWorkspace = useMemo(() => { const senderWorkspaceParticipant = selectedParticipants.find((participant) => participant.isSender); @@ -787,7 +787,7 @@ function MoneyRequestConfirmationListFooter({ disabled={didConfirm} /> )} - {showMapAsImage && ( + {shouldShowMap && ( @@ -832,7 +832,7 @@ function MoneyRequestConfirmationListFooter({ )} - {!showMapAsImage && + {!shouldShowMap && // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing (receiptImage || receiptThumbnail ? receiptThumbnailContent