1
1
import React , { useCallback , useMemo } from 'react' ;
2
2
import { View } from 'react-native' ;
3
- import type { OnyxEntry } from 'react-native-onyx' ;
4
3
import { useOnyx } from 'react-native-onyx' ;
4
+ import type { OnyxEntry } from 'react-native-onyx' ;
5
5
import * as Expensicons from '@components/Icon/Expensicons' ;
6
6
import MenuItem from '@components/MenuItem' ;
7
7
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription' ;
@@ -16,15 +16,14 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'
16
16
import useLocalize from '@hooks/useLocalize' ;
17
17
import useNetwork from '@hooks/useNetwork' ;
18
18
import useThemeStyles from '@hooks/useThemeStyles' ;
19
- import type { ViolationField } from '@hooks/useViolations' ;
20
19
import useViolations from '@hooks/useViolations' ;
20
+ import type { ViolationField } from '@hooks/useViolations' ;
21
21
import { convertToDisplayString } from '@libs/CurrencyUtils' ;
22
22
import DistanceRequestUtils from '@libs/DistanceRequestUtils' ;
23
23
import { hasEnabledOptions } from '@libs/OptionsListUtils' ;
24
24
import { getTagLists , hasDependentTags , isTaxTrackingEnabled } from '@libs/PolicyUtils' ;
25
25
import { getThumbnailAndImageURIs } from '@libs/ReceiptUtils' ;
26
26
import { getOriginalMessage , isMoneyRequestAction , isPayAction } from '@libs/ReportActionsUtils' ;
27
- import type { TransactionDetails } from '@libs/ReportUtils' ;
28
27
import {
29
28
canEditFieldOfMoneyRequest ,
30
29
canEditMoneyRequest ,
@@ -40,6 +39,7 @@ import {
40
39
isSettled as isSettledReportUtils ,
41
40
isTrackExpenseReport ,
42
41
} from '@libs/ReportUtils' ;
42
+ import type { TransactionDetails } from '@libs/ReportUtils' ;
43
43
import { hasEnabledTags } from '@libs/TagsOptionsListUtils' ;
44
44
import {
45
45
didReceiptScanSucceed as didReceiptScanSucceedTransactionUtils ,
@@ -70,13 +70,13 @@ import CONST from '@src/CONST';
70
70
import type { TranslationPaths } from '@src/languages/types' ;
71
71
import ONYXKEYS from '@src/ONYXKEYS' ;
72
72
import ROUTES from '@src/ROUTES' ;
73
- import type { Report , Transaction , TransactionViolation , ViolationName } from '@src/types/onyx' ;
73
+ import type * as OnyxTypes from '@src/types/onyx' ;
74
74
import type { TransactionPendingFieldsKey } from '@src/types/onyx/Transaction' ;
75
75
import ReportActionItemImage from './ReportActionItemImage' ;
76
76
77
77
type MoneyRequestViewProps = {
78
78
/** The report currently being looked at */
79
- report : OnyxEntry < Report > ;
79
+ report : OnyxEntry < OnyxTypes . Report > ;
80
80
81
81
/** Whether we should display the animated banner above the component */
82
82
shouldShowAnimatedBackground : boolean ;
@@ -88,17 +88,17 @@ type MoneyRequestViewProps = {
88
88
isFromReviewDuplicates ?: boolean ;
89
89
90
90
/** Updated transaction to show in duplicate transaction flow */
91
- updatedTransaction ?: OnyxEntry < Transaction > ;
91
+ updatedTransaction ?: OnyxEntry < OnyxTypes . Transaction > ;
92
92
} ;
93
93
94
- const receiptImageViolationNames : ViolationName [ ] = [
94
+ const receiptImageViolationNames : OnyxTypes . ViolationName [ ] = [
95
95
CONST . VIOLATIONS . RECEIPT_REQUIRED ,
96
96
CONST . VIOLATIONS . RECEIPT_NOT_SMART_SCANNED ,
97
97
CONST . VIOLATIONS . CASH_EXPENSE_WITH_NO_RECEIPT ,
98
98
CONST . VIOLATIONS . SMARTSCAN_FAILED ,
99
99
] ;
100
100
101
- const receiptFieldViolationNames : ViolationName [ ] = [ CONST . VIOLATIONS . MODIFIED_AMOUNT , CONST . VIOLATIONS . MODIFIED_DATE ] ;
101
+ const receiptFieldViolationNames : OnyxTypes . ViolationName [ ] = [ CONST . VIOLATIONS . MODIFIED_AMOUNT , CONST . VIOLATIONS . MODIFIED_DATE ] ;
102
102
103
103
function MoneyRequestView ( { report, shouldShowAnimatedBackground, readonly = false , updatedTransaction, isFromReviewDuplicates = false } : MoneyRequestViewProps ) {
104
104
const styles = useThemeStyles ( ) ;
@@ -219,7 +219,7 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals
219
219
220
220
const { getViolationsForField} = useViolations ( transactionViolations ?? [ ] , isReceiptBeingScanned || ! isPaidGroupPolicy ( report ) ) ;
221
221
const hasViolations = useCallback (
222
- ( field : ViolationField , data ?: TransactionViolation [ 'data' ] , policyHasDependentTags = false , tagValue ?: string ) : boolean =>
222
+ ( field : ViolationField , data ?: OnyxTypes . TransactionViolation [ 'data' ] , policyHasDependentTags = false , tagValue ?: string ) : boolean =>
223
223
getViolationsForField ( field , data , policyHasDependentTags , tagValue ) . length > 0 ,
224
224
[ getViolationsForField ] ,
225
225
) ;
@@ -293,7 +293,7 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals
293
293
const getPendingFieldAction = ( fieldPath : TransactionPendingFieldsKey ) => ( pendingAction ? undefined : transaction ?. pendingFields ?. [ fieldPath ] ) ;
294
294
295
295
const getErrorForField = useCallback (
296
- ( field : ViolationField , data ?: TransactionViolation [ 'data' ] , policyHasDependentTags = false , tagValue ?: string ) => {
296
+ ( field : ViolationField , data ?: OnyxTypes . TransactionViolation [ 'data' ] , policyHasDependentTags = false , tagValue ?: string ) => {
297
297
// Checks applied when creating a new expense
298
298
// NOTE: receipt field can return multiple violations, so we need to handle it separately
299
299
const fieldChecks : Partial < Record < ViolationField , { isError : boolean ; translationPath : TranslationPaths } > > = {
@@ -538,7 +538,6 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals
538
538
< ReceiptEmptyState
539
539
hasError = { hasErrors }
540
540
disabled = { ! canEditReceipt }
541
- transactionID = { transaction ?. transactionID }
542
541
onPress = { ( ) => {
543
542
if ( ! transaction ?. transactionID || ! report ?. reportID ) {
544
543
return ;
0 commit comments