-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
MoneyRequestConfirmationListFooter.tsx
693 lines (634 loc) · 31.5 KB
/
MoneyRequestConfirmationListFooter.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
import {format} from 'date-fns';
import {Str} from 'expensify-common';
import lodashIsEqual from 'lodash/isEqual';
import React, {memo, useMemo, useReducer} from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {useOnyx} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import DistanceRequestUtils from '@libs/DistanceRequestUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReceiptUtils from '@libs/ReceiptUtils';
import {getDefaultWorkspaceAvatar} from '@libs/ReportUtils';
import * as TransactionUtils from '@libs/TransactionUtils';
import tryResolveUrlFromApiRoot from '@libs/tryResolveUrlFromApiRoot';
import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow';
import CONST from '@src/CONST';
import type {IOUAction, IOUType} from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type * as OnyxTypes from '@src/types/onyx';
import type {Participant} from '@src/types/onyx/IOU';
import type {Unit} from '@src/types/onyx/Policy';
import ConfirmedRoute from './ConfirmedRoute';
import MentionReportContext from './HTMLEngineProvider/HTMLRenderers/MentionReportRenderer/MentionReportContext';
import MenuItem from './MenuItem';
import MenuItemWithTopDescription from './MenuItemWithTopDescription';
import PDFThumbnail from './PDFThumbnail';
import PressableWithoutFocus from './Pressable/PressableWithoutFocus';
import ReceiptEmptyState from './ReceiptEmptyState';
import ReceiptImage from './ReceiptImage';
import ShowMoreButton from './ShowMoreButton';
type MoneyRequestConfirmationListFooterProps = {
/** The action to perform */
action: IOUAction;
/** Flag indicating if P2P distance requests can be used */
canUseP2PDistanceRequests: boolean | undefined;
/** The currency of the transaction */
currency: string;
/** Flag indicating if the confirmation is done */
didConfirm: boolean;
/** The distance of the transaction */
distance: number;
/** The formatted amount of the transaction */
formattedAmount: string;
/** The error message for the form */
formError: string;
/** Flag indicating if there is a route */
hasRoute: boolean;
/** The category of the IOU */
iouCategory: string;
/** The comment of the IOU */
iouComment: string | undefined;
/** The creation date of the IOU */
iouCreated: string | undefined;
/** The currency code of the IOU */
iouCurrencyCode: string | undefined;
/** Flag indicating if the IOU is billable */
iouIsBillable: boolean;
/** The merchant of the IOU */
iouMerchant: string | undefined;
/** The type of the IOU */
iouType: Exclude<IOUType, typeof CONST.IOU.TYPE.REQUEST | typeof CONST.IOU.TYPE.SEND>;
/** Flag indicating if the category is required */
isCategoryRequired: boolean;
/** Flag indicating if it is a distance request */
isDistanceRequest: boolean;
/** Flag indicating if it is editing a split bill */
isEditingSplitBill: boolean | undefined;
/** Flag indicating if the merchant is empty */
isMerchantEmpty: boolean;
/** Flag indicating if the merchant is required */
isMerchantRequired: boolean | undefined;
/** Flag indicating if the transaction is moved from track expense */
isMovingTransactionFromTrackExpense: boolean;
/** Flag indicating if it is a policy expense chat */
isPolicyExpenseChat: boolean;
/** Flag indicating if it is read-only */
isReadOnly: boolean;
/** Flag indicating if it is an invoice type */
isTypeInvoice: boolean;
/** Function to toggle billable */
onToggleBillable?: (isOn: boolean) => void;
/** The policy */
policy: OnyxEntry<OnyxTypes.Policy>;
/** The policy tag lists */
policyTags: OnyxEntry<OnyxTypes.PolicyTagLists>;
/** The policy tag lists */
policyTagLists: Array<ValueOf<OnyxTypes.PolicyTagLists>>;
/** The rate of the transaction */
rate: number | undefined;
/** The filename of the receipt */
receiptFilename: string;
/** The path of the receipt */
receiptPath: string;
/** The report action ID */
reportActionID: string | undefined;
/** The report ID */
reportID: string;
/** The selected participants */
selectedParticipants: Participant[];
/** Flag indicating if the field error should be displayed */
shouldDisplayFieldError: boolean;
/** Flag indicating if the receipt should be displayed */
shouldDisplayReceipt: boolean;
/** Flag indicating if the categories should be shown */
shouldShowCategories: boolean;
/** Flag indicating if the merchant should be shown */
shouldShowMerchant: boolean;
/** Flag indicating if the smart scan fields should be shown */
shouldShowSmartScanFields: boolean;
/** Flag indicating if the tax should be shown */
shouldShowTax: boolean;
/** The transaction */
transaction: OnyxEntry<OnyxTypes.Transaction>;
/** The transaction ID */
transactionID: string;
/** The unit */
unit: Unit | undefined;
};
function MoneyRequestConfirmationListFooter({
action,
canUseP2PDistanceRequests,
currency,
didConfirm,
distance,
formattedAmount,
formError,
hasRoute,
iouCategory,
iouComment,
iouCreated,
iouCurrencyCode,
iouIsBillable,
iouMerchant,
iouType,
isCategoryRequired,
isDistanceRequest,
isEditingSplitBill,
isMerchantEmpty,
isMerchantRequired,
isMovingTransactionFromTrackExpense,
isPolicyExpenseChat,
isReadOnly,
isTypeInvoice,
onToggleBillable,
policy,
policyTags,
policyTagLists,
rate,
receiptFilename,
receiptPath,
reportActionID,
reportID,
selectedParticipants,
shouldDisplayFieldError,
shouldDisplayReceipt,
shouldShowCategories,
shouldShowMerchant,
shouldShowSmartScanFields,
shouldShowTax,
transaction,
transactionID,
unit,
}: MoneyRequestConfirmationListFooterProps) {
const styles = useThemeStyles();
const theme = useTheme();
const {translate, toLocaleDigit} = useLocalize();
const {isOffline} = useNetwork();
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const [currentUserLogin] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.email});
// A flag and a toggler for showing the rest of the form fields
const [shouldExpandFields, toggleShouldExpandFields] = useReducer((state) => !state, false);
const shouldShowTags = useMemo(() => isPolicyExpenseChat && OptionsListUtils.hasEnabledTags(policyTagLists), [isPolicyExpenseChat, policyTagLists]);
const isMultilevelTags = useMemo(() => PolicyUtils.isMultiLevelTags(policyTags), [policyTags]);
const senderWorkspace = useMemo(() => {
const senderWorkspaceParticipant = selectedParticipants.find((participant) => participant.isSender);
return allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${senderWorkspaceParticipant?.policyID}`];
}, [allPolicies, selectedParticipants]);
const canUpdateSenderWorkspace = useMemo(() => {
const isInvoiceRoomParticipant = selectedParticipants.some((participant) => participant.isInvoiceRoom);
return PolicyUtils.canSendInvoice(allPolicies, currentUserLogin) && !!transaction?.isFromGlobalCreate && !isInvoiceRoomParticipant;
}, [allPolicies, currentUserLogin, selectedParticipants, transaction?.isFromGlobalCreate]);
const isTypeSend = iouType === CONST.IOU.TYPE.PAY;
const taxRates = policy?.taxRates ?? null;
// In Send Money and Split Bill with Scan flow, we don't allow the Merchant or Date to be edited. For distance requests, don't show the merchant as there's already another "Distance" menu item
const shouldShowDate = (shouldShowSmartScanFields || isDistanceRequest) && !isTypeSend;
// Determines whether the tax fields can be modified.
// The tax fields can only be modified if the component is not in read-only mode
// and it is not a distance request.
const canModifyTaxFields = !isReadOnly && !isDistanceRequest;
// A flag for showing the billable field
const shouldShowBillable = policy?.disabledFields?.defaultBillable === false;
// Do not hide fields in case of paying someone
const shouldShowAllFields = !!isDistanceRequest || shouldExpandFields || !shouldShowSmartScanFields || isTypeSend || !!isEditingSplitBill;
// Calculate the formatted tax amount based on the transaction's tax amount and the IOU currency code
const taxAmount = TransactionUtils.getTaxAmount(transaction, false);
const formattedTaxAmount = CurrencyUtils.convertToDisplayString(taxAmount, iouCurrencyCode);
// Get the tax rate title based on the policy and transaction
const taxRateTitle = TransactionUtils.getTaxName(policy, transaction);
// Determine if the merchant error should be displayed
const shouldDisplayMerchantError = isMerchantRequired && (shouldDisplayFieldError || formError === 'iou.error.invalidMerchant') && isMerchantEmpty;
// The empty receipt component should only show for IOU Requests of a paid policy ("Team" or "Corporate")
const shouldShowReceiptEmptyState = iouType === CONST.IOU.TYPE.SUBMIT && PolicyUtils.isPaidGroupPolicy(policy);
const {
image: receiptImage,
thumbnail: receiptThumbnail,
isThumbnail,
fileExtension,
isLocalFile,
} = receiptPath && receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction, receiptPath, receiptFilename) : ({} as ReceiptUtils.ThumbnailAndImageURI);
const resolvedThumbnail = isLocalFile ? receiptThumbnail : tryResolveUrlFromApiRoot(receiptThumbnail ?? '');
const resolvedReceiptImage = isLocalFile ? receiptImage : tryResolveUrlFromApiRoot(receiptImage ?? '');
const mentionReportContextValue = useMemo(() => ({currentReportID: reportID}), [reportID]);
// An intermediate structure that helps us classify the fields as "primary" and "supplementary".
// The primary fields are always shown to the user, while an extra action is needed to reveal the supplementary ones.
const classifiedFields = [
{
item: (
<MenuItemWithTopDescription
key={translate('iou.amount')}
shouldShowRightIcon={!isReadOnly && !isDistanceRequest}
title={formattedAmount}
description={translate('iou.amount')}
interactive={!isReadOnly}
onPress={() => {
if (isDistanceRequest) {
return;
}
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()));
}}
style={[styles.moneyRequestMenuItem, styles.mt2]}
titleStyle={styles.moneyRequestConfirmationAmount}
disabled={didConfirm}
brickRoadIndicator={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
errorText={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction) ? translate('common.error.enterAmount') : ''}
/>
),
shouldShow: shouldShowSmartScanFields,
isSupplementary: false,
},
{
item: (
<MentionReportContext.Provider value={mentionReportContextValue}>
<MenuItemWithTopDescription
key={translate('common.description')}
shouldShowRightIcon={!isReadOnly}
shouldParseTitle
excludedMarkdownRules={!policy ? ['reportMentions'] : []}
title={iouComment}
description={translate('common.description')}
onPress={() => {
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams(), reportActionID),
);
}}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
disabled={didConfirm}
interactive={!isReadOnly}
numberOfLinesTitle={2}
/>
</MentionReportContext.Provider>
),
shouldShow: true,
isSupplementary: false,
},
{
item: (
<MenuItemWithTopDescription
key={translate('common.distance')}
shouldShowRightIcon={!isReadOnly && !isMovingTransactionFromTrackExpense}
title={isMerchantEmpty ? '' : iouMerchant}
description={translate('common.distance')}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()))}
disabled={didConfirm}
// todo: handle edit for transaction while moving from track expense
interactive={!isReadOnly && !isMovingTransactionFromTrackExpense}
/>
),
shouldShow: isDistanceRequest && !canUseP2PDistanceRequests,
isSupplementary: false,
},
{
item: (
<MenuItemWithTopDescription
key={translate('common.distance')}
shouldShowRightIcon={!isReadOnly}
title={DistanceRequestUtils.getDistanceForDisplay(hasRoute, distance, unit, rate, translate)}
description={translate('common.distance')}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()))}
disabled={didConfirm}
interactive={!isReadOnly}
/>
),
shouldShow: isDistanceRequest && canUseP2PDistanceRequests,
isSupplementary: false,
},
{
item: (
<MenuItemWithTopDescription
key={translate('common.rate')}
shouldShowRightIcon={!!rate && !isReadOnly && isPolicyExpenseChat}
title={DistanceRequestUtils.getRateForDisplay(unit, rate, currency, translate, toLocaleDigit, isOffline)}
description={translate('common.rate')}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE_RATE.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()))}
disabled={didConfirm}
interactive={!!rate && !isReadOnly && isPolicyExpenseChat}
/>
),
shouldShow: isDistanceRequest && canUseP2PDistanceRequests,
isSupplementary: false,
},
{
item: (
<MenuItemWithTopDescription
key={translate('common.merchant')}
shouldShowRightIcon={!isReadOnly}
title={isMerchantEmpty ? '' : iouMerchant}
description={translate('common.merchant')}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
onPress={() => {
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()));
}}
disabled={didConfirm}
interactive={!isReadOnly}
brickRoadIndicator={shouldDisplayMerchantError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
errorText={shouldDisplayMerchantError ? translate('common.error.fieldRequired') : ''}
rightLabel={isMerchantRequired && !shouldDisplayMerchantError ? translate('common.required') : ''}
numberOfLinesTitle={2}
/>
),
shouldShow: shouldShowMerchant,
isSupplementary: !isMerchantRequired,
},
{
item: (
<MenuItemWithTopDescription
key={translate('common.date')}
shouldShowRightIcon={!isReadOnly}
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
title={iouCreated || format(new Date(), CONST.DATE.FNS_FORMAT_STRING)}
description={translate('common.date')}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
onPress={() => {
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams(), reportActionID));
}}
disabled={didConfirm}
interactive={!isReadOnly}
brickRoadIndicator={shouldDisplayFieldError && TransactionUtils.isCreatedMissing(transaction) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
errorText={shouldDisplayFieldError && TransactionUtils.isCreatedMissing(transaction) ? translate('common.error.enterDate') : ''}
/>
),
shouldShow: shouldShowDate,
isSupplementary: true,
},
{
item: (
<MenuItemWithTopDescription
key={translate('common.category')}
shouldShowRightIcon={!isReadOnly}
title={iouCategory}
description={translate('common.category')}
numberOfLinesTitle={2}
onPress={() =>
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams(), reportActionID))
}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
disabled={didConfirm}
interactive={!isReadOnly}
rightLabel={isCategoryRequired ? translate('common.required') : ''}
/>
),
shouldShow: shouldShowCategories,
isSupplementary: action === CONST.IOU.ACTION.CATEGORIZE ? false : !isCategoryRequired,
},
...policyTagLists.map(({name, required, tags}, index) => {
const isTagRequired = required ?? false;
const shouldShow = shouldShowTags && (!isMultilevelTags || OptionsListUtils.hasEnabledOptions(tags));
return {
item: (
<MenuItemWithTopDescription
key={name}
shouldShowRightIcon={!isReadOnly}
title={TransactionUtils.getTagForDisplay(transaction, index)}
description={name}
numberOfLinesTitle={2}
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(action, iouType, index, transactionID, reportID, Navigation.getActiveRouteWithoutParams(), reportActionID),
)
}
style={[styles.moneyRequestMenuItem]}
disabled={didConfirm}
interactive={!isReadOnly}
rightLabel={isTagRequired ? translate('common.required') : ''}
/>
),
shouldShow,
isSupplementary: !isTagRequired,
};
}),
{
item: (
<MenuItemWithTopDescription
key={`${taxRates?.name}${taxRateTitle}`}
shouldShowRightIcon={canModifyTaxFields}
title={taxRateTitle}
description={taxRates?.name}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()))}
disabled={didConfirm}
interactive={canModifyTaxFields}
/>
),
shouldShow: shouldShowTax,
isSupplementary: true,
},
{
item: (
<MenuItemWithTopDescription
key={`${taxRates?.name}${formattedTaxAmount}`}
shouldShowRightIcon={canModifyTaxFields}
title={formattedTaxAmount}
description={translate('iou.taxAmount')}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()))}
disabled={didConfirm}
interactive={canModifyTaxFields}
/>
),
shouldShow: shouldShowTax,
isSupplementary: true,
},
{
item: (
<View style={[styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, styles.ml5, styles.mr8, styles.optionRow]}>
<ToggleSettingOptionRow
switchAccessibilityLabel={translate('common.billable')}
title={translate('common.billable')}
onToggle={(isOn) => onToggleBillable?.(isOn)}
isActive={iouIsBillable}
disabled={isReadOnly}
titleStyle={!iouIsBillable && {color: theme.textSupporting}}
wrapperStyle={styles.flex1}
/>
</View>
),
shouldShow: shouldShowBillable,
isSupplementary: true,
},
];
const primaryFields: JSX.Element[] = [];
const supplementaryFields: JSX.Element[] = [];
classifiedFields.forEach((field) => {
if (field.shouldShow && !field.isSupplementary) {
primaryFields.push(field.item);
} else if (field.shouldShow && field.isSupplementary) {
supplementaryFields.push(field.item);
}
});
const receiptThumbnailContent = useMemo(
() => (
<View style={styles.moneyRequestImage}>
{isLocalFile && Str.isPDF(receiptFilename) ? (
<PressableWithoutFocus
onPress={() => Navigation.navigate(ROUTES.TRANSACTION_RECEIPT.getRoute(reportID ?? '', transactionID ?? ''))}
accessibilityRole={CONST.ROLE.BUTTON}
accessibilityLabel={translate('accessibilityHints.viewAttachment')}
disabled={!shouldDisplayReceipt}
disabledStyle={styles.cursorDefault}
>
<PDFThumbnail
// eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style
previewSourceURL={resolvedReceiptImage as string}
/>
</PressableWithoutFocus>
) : (
<PressableWithoutFocus
onPress={() => Navigation.navigate(ROUTES.TRANSACTION_RECEIPT.getRoute(reportID ?? '', transactionID ?? ''))}
disabled={!shouldDisplayReceipt || isThumbnail}
accessibilityRole={CONST.ROLE.BUTTON}
accessibilityLabel={translate('accessibilityHints.viewAttachment')}
disabledStyle={styles.cursorDefault}
>
<ReceiptImage
isThumbnail={isThumbnail}
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
source={resolvedThumbnail || resolvedReceiptImage || ''}
// AuthToken is required when retrieving the image from the server
// but we don't need it to load the blob:// or file:// image when starting an expense/split
// So if we have a thumbnail, it means we're retrieving the image from the server
isAuthTokenRequired={!!receiptThumbnail && !isLocalFile}
fileExtension={fileExtension}
shouldUseThumbnailImage
shouldUseInitialObjectPosition={isDistanceRequest}
/>
</PressableWithoutFocus>
)}
</View>
),
[
styles.moneyRequestImage,
styles.cursorDefault,
isLocalFile,
receiptFilename,
translate,
shouldDisplayReceipt,
resolvedReceiptImage,
isThumbnail,
resolvedThumbnail,
receiptThumbnail,
fileExtension,
isDistanceRequest,
reportID,
transactionID,
],
);
return (
<>
{isTypeInvoice && (
<MenuItem
key={translate('workspace.invoices.sendFrom')}
avatarID={senderWorkspace?.id}
shouldShowRightIcon={!isReadOnly && canUpdateSenderWorkspace}
title={senderWorkspace?.name}
icon={senderWorkspace?.avatarURL ? senderWorkspace?.avatarURL : getDefaultWorkspaceAvatar(senderWorkspace?.name)}
iconType={CONST.ICON_TYPE_WORKSPACE}
description={translate('workspace.common.workspace')}
label={translate('workspace.invoices.sendFrom')}
isLabelHoverable={false}
interactive={!isReadOnly && canUpdateSenderWorkspace}
onPress={() => {
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_SEND_FROM.getRoute(iouType, transaction?.transactionID ?? '-1', reportID, Navigation.getActiveRouteWithoutParams()));
}}
style={styles.moneyRequestMenuItem}
labelStyle={styles.mt2}
titleStyle={styles.flex1}
disabled={didConfirm}
/>
)}
{isDistanceRequest && (
<View style={styles.confirmationListMapItem}>
<ConfirmedRoute transaction={transaction ?? ({} as OnyxTypes.Transaction)} />
</View>
)}
{!isDistanceRequest &&
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
(receiptImage || receiptThumbnail
? receiptThumbnailContent
: shouldShowReceiptEmptyState && (
<ReceiptEmptyState
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams()),
)
}
/>
))}
{primaryFields}
{!shouldShowAllFields && (
<ShowMoreButton
containerStyle={[styles.mt1, styles.mb2]}
onPress={toggleShouldExpandFields}
/>
)}
<View style={[styles.mb5]}>{shouldShowAllFields && supplementaryFields}</View>
</>
);
}
MoneyRequestConfirmationListFooter.displayName = 'MoneyRequestConfirmationListFooter';
export default memo(
MoneyRequestConfirmationListFooter,
(prevProps, nextProps) =>
lodashIsEqual(prevProps.action, nextProps.action) &&
prevProps.canUseP2PDistanceRequests === nextProps.canUseP2PDistanceRequests &&
prevProps.currency === nextProps.currency &&
prevProps.didConfirm === nextProps.didConfirm &&
prevProps.distance === nextProps.distance &&
prevProps.formattedAmount === nextProps.formattedAmount &&
prevProps.formError === nextProps.formError &&
prevProps.hasRoute === nextProps.hasRoute &&
prevProps.iouCategory === nextProps.iouCategory &&
prevProps.iouComment === nextProps.iouComment &&
prevProps.iouCreated === nextProps.iouCreated &&
prevProps.iouCurrencyCode === nextProps.iouCurrencyCode &&
prevProps.iouIsBillable === nextProps.iouIsBillable &&
prevProps.iouMerchant === nextProps.iouMerchant &&
prevProps.iouType === nextProps.iouType &&
prevProps.isCategoryRequired === nextProps.isCategoryRequired &&
prevProps.isDistanceRequest === nextProps.isDistanceRequest &&
prevProps.isEditingSplitBill === nextProps.isEditingSplitBill &&
prevProps.isMerchantEmpty === nextProps.isMerchantEmpty &&
prevProps.isMerchantRequired === nextProps.isMerchantRequired &&
prevProps.isMovingTransactionFromTrackExpense === nextProps.isMovingTransactionFromTrackExpense &&
prevProps.isPolicyExpenseChat === nextProps.isPolicyExpenseChat &&
prevProps.isReadOnly === nextProps.isReadOnly &&
prevProps.isTypeInvoice === nextProps.isTypeInvoice &&
prevProps.onToggleBillable === nextProps.onToggleBillable &&
lodashIsEqual(prevProps.policy, nextProps.policy) &&
lodashIsEqual(prevProps.policyTagLists, nextProps.policyTagLists) &&
prevProps.rate === nextProps.rate &&
prevProps.receiptFilename === nextProps.receiptFilename &&
prevProps.receiptPath === nextProps.receiptPath &&
prevProps.reportActionID === nextProps.reportActionID &&
prevProps.reportID === nextProps.reportID &&
lodashIsEqual(prevProps.selectedParticipants, nextProps.selectedParticipants) &&
prevProps.shouldDisplayFieldError === nextProps.shouldDisplayFieldError &&
prevProps.shouldDisplayReceipt === nextProps.shouldDisplayReceipt &&
prevProps.shouldShowCategories === nextProps.shouldShowCategories &&
prevProps.shouldShowMerchant === nextProps.shouldShowMerchant &&
prevProps.shouldShowSmartScanFields === nextProps.shouldShowSmartScanFields &&
prevProps.shouldShowTax === nextProps.shouldShowTax &&
lodashIsEqual(prevProps.transaction, nextProps.transaction) &&
prevProps.transactionID === nextProps.transactionID &&
prevProps.unit === nextProps.unit,
);