@@ -3,11 +3,29 @@ import {useOnyx} from 'react-native-onyx';
3
3
import type { OnyxEntry } from 'react-native-onyx' ;
4
4
import { useBlockedFromConcierge , usePersonalDetails } from '@components/OnyxProvider' ;
5
5
import ModifiedExpenseMessage from '@libs/ModifiedExpenseMessage' ;
6
- import * as ReportActionsUtils from '@libs/ReportActionsUtils' ;
7
- import * as ReportUtils from '@libs/ReportUtils' ;
8
- import * as Report from '@userActions/Report' ;
9
- import * as ReportActions from '@userActions/ReportActions' ;
10
- import * as Transaction from '@userActions/Transaction' ;
6
+ import { getIOUReportIDFromReportActionPreview , getOriginalMessage , isMoneyRequestAction } from '@libs/ReportActionsUtils' ;
7
+ import {
8
+ chatIncludesChronosWithID ,
9
+ createDraftTransactionAndNavigateToParticipantSelector ,
10
+ getIndicatedMissingPaymentMethod ,
11
+ getOriginalReportID ,
12
+ getReimbursementDeQueuedOrCanceledActionMessage ,
13
+ getReportAutomaticallyForwardedMessage ,
14
+ getTransactionsWithReceipts ,
15
+ isArchivedNonExpenseReportWithID ,
16
+ isChatThread ,
17
+ isClosedExpenseReportWithNoExpenses ,
18
+ isCurrentUserTheOnlyParticipant ,
19
+ } from '@libs/ReportUtils' ;
20
+ import {
21
+ deleteReportActionDraft ,
22
+ dismissTrackExpenseActionableWhisper ,
23
+ resolveActionableMentionWhisper ,
24
+ resolveActionableReportMentionWhisper ,
25
+ toggleEmojiReaction ,
26
+ } from '@userActions/Report' ;
27
+ import { clearAllRelatedReportActionErrors } from '@userActions/ReportActions' ;
28
+ import { clearError } from '@userActions/Transaction' ;
11
29
import type CONST from '@src/CONST' ;
12
30
import ONYXKEYS from '@src/ONYXKEYS' ;
13
31
import type { ReportAction } from '@src/types/onyx' ;
@@ -17,20 +35,19 @@ import PureReportActionItem from './PureReportActionItem';
17
35
function ReportActionItem ( { action, report, ...props } : PureReportActionItemProps ) {
18
36
const reportID = report ?. reportID ;
19
37
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
20
- const originalReportID = useMemo ( ( ) => ReportUtils . getOriginalReportID ( reportID , action ) , [ reportID , action ] ) ;
38
+ const originalReportID = useMemo ( ( ) => getOriginalReportID ( reportID , action ) , [ reportID , action ] ) ;
21
39
const [ draftMessage ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS_DRAFTS } ${ originalReportID } ` , {
22
40
selector : ( draftMessagesForReport ) => {
23
41
const matchingDraftMessage = draftMessagesForReport ?. [ action . reportActionID ] ;
24
42
return typeof matchingDraftMessage === 'string' ? matchingDraftMessage : matchingDraftMessage ?. message ;
25
43
} ,
26
44
} ) ;
27
- const [ iouReport ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ ReportActionsUtils . getIOUReportIDFromReportActionPreview ( action ) } ` ) ;
45
+ const [ iouReport ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ getIOUReportIDFromReportActionPreview ( action ) } ` ) ;
28
46
const [ emojiReactions ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS_REACTIONS } ${ action . reportActionID } ` ) ;
29
47
const [ userWallet ] = useOnyx ( ONYXKEYS . USER_WALLET ) ;
30
- const [ linkedTransactionRouteError ] = useOnyx (
31
- `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ ReportActionsUtils . isMoneyRequestAction ( action ) && ReportActionsUtils . getOriginalMessage ( action ) ?. IOUTransactionID } ` ,
32
- { selector : ( transaction ) => transaction ?. errorFields ?. route ?? null } ,
33
- ) ;
48
+ const [ linkedTransactionRouteError ] = useOnyx ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ isMoneyRequestAction ( action ) && getOriginalMessage ( action ) ?. IOUTransactionID } ` , {
49
+ selector : ( transaction ) => transaction ?. errorFields ?. route ?? null ,
50
+ } ) ;
34
51
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- This is needed to prevent the app from crashing when the app is using imported state.
35
52
const [ reportNameValuePairs ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT_NAME_VALUE_PAIRS } ${ report ?. reportID || undefined } ` ) ;
36
53
@@ -41,8 +58,8 @@ function ReportActionItem({action, report, ...props}: PureReportActionItemProps)
41
58
const personalDetails = usePersonalDetails ( ) ;
42
59
const blockedFromConcierge = useBlockedFromConcierge ( ) ;
43
60
const [ userBillingFundID ] = useOnyx ( ONYXKEYS . NVP_BILLING_FUND_ID ) ;
44
- const linkedReport = ReportUtils . isChatThread ( report ) ? parentReport : report ;
45
- const missingPaymentMethod = ReportUtils . getIndicatedMissingPaymentMethod ( userWallet , linkedReport ?. reportID , action ) ;
61
+ const linkedReport = isChatThread ( report ) ? parentReport : report ;
62
+ const missingPaymentMethod = getIndicatedMissingPaymentMethod ( userWallet , linkedReport ?. reportID , action ) ;
46
63
47
64
return (
48
65
< PureReportActionItem
@@ -60,27 +77,27 @@ function ReportActionItem({action, report, ...props}: PureReportActionItemProps)
60
77
personalDetails = { personalDetails }
61
78
blockedFromConcierge = { blockedFromConcierge }
62
79
originalReportID = { originalReportID }
63
- deleteReportActionDraft = { Report . deleteReportActionDraft }
64
- isArchivedRoom = { ReportUtils . isArchivedNonExpenseReportWithID ( originalReportID ) }
65
- isChronosReport = { ReportUtils . chatIncludesChronosWithID ( originalReportID ) }
66
- toggleEmojiReaction = { Report . toggleEmojiReaction }
67
- createDraftTransactionAndNavigateToParticipantSelector = { ReportUtils . createDraftTransactionAndNavigateToParticipantSelector }
68
- resolveActionableReportMentionWhisper = { Report . resolveActionableReportMentionWhisper }
69
- resolveActionableMentionWhisper = { Report . resolveActionableMentionWhisper }
70
- isClosedExpenseReportWithNoExpenses = { ReportUtils . isClosedExpenseReportWithNoExpenses ( iouReport ) }
71
- isCurrentUserTheOnlyParticipant = { ReportUtils . isCurrentUserTheOnlyParticipant }
80
+ deleteReportActionDraft = { deleteReportActionDraft }
81
+ isArchivedRoom = { isArchivedNonExpenseReportWithID ( originalReportID ) }
82
+ isChronosReport = { chatIncludesChronosWithID ( originalReportID ) }
83
+ toggleEmojiReaction = { toggleEmojiReaction }
84
+ createDraftTransactionAndNavigateToParticipantSelector = { createDraftTransactionAndNavigateToParticipantSelector }
85
+ resolveActionableReportMentionWhisper = { resolveActionableReportMentionWhisper }
86
+ resolveActionableMentionWhisper = { resolveActionableMentionWhisper }
87
+ isClosedExpenseReportWithNoExpenses = { isClosedExpenseReportWithNoExpenses ( iouReport ) }
88
+ isCurrentUserTheOnlyParticipant = { isCurrentUserTheOnlyParticipant }
72
89
missingPaymentMethod = { missingPaymentMethod }
73
- reimbursementDeQueuedActionMessage = { ReportUtils . getReimbursementDeQueuedActionMessage (
74
- action as OnyxEntry < ReportAction < typeof CONST . REPORT . ACTIONS . TYPE . REIMBURSEMENT_DEQUEUED > > ,
90
+ reimbursementDeQueuedOrCanceledActionMessage = { getReimbursementDeQueuedOrCanceledActionMessage (
91
+ action as OnyxEntry < ReportAction < typeof CONST . REPORT . ACTIONS . TYPE . REIMBURSEMENT_DEQUEUED | typeof CONST . REPORT . ACTIONS . TYPE . REIMBURSEMENT_ACH_CANCELED > > ,
75
92
report ,
76
93
) }
77
94
modifiedExpenseMessage = { ModifiedExpenseMessage . getForReportAction ( { reportOrID : reportID , reportAction : action } ) }
78
- getTransactionsWithReceipts = { ReportUtils . getTransactionsWithReceipts }
79
- clearError = { Transaction . clearError }
80
- clearAllRelatedReportActionErrors = { ReportActions . clearAllRelatedReportActionErrors }
81
- dismissTrackExpenseActionableWhisper = { Report . dismissTrackExpenseActionableWhisper }
95
+ getTransactionsWithReceipts = { getTransactionsWithReceipts }
96
+ clearError = { clearError }
97
+ clearAllRelatedReportActionErrors = { clearAllRelatedReportActionErrors }
98
+ dismissTrackExpenseActionableWhisper = { dismissTrackExpenseActionableWhisper }
82
99
userBillingFundID = { userBillingFundID }
83
- reportAutomaticallyForwardedMessage = { ReportUtils . getReportAutomaticallyForwardedMessage ( action as ReportAction < typeof CONST . REPORT . ACTIONS . TYPE . FORWARDED > , reportID ) }
100
+ reportAutomaticallyForwardedMessage = { getReportAutomaticallyForwardedMessage ( action as ReportAction < typeof CONST . REPORT . ACTIONS . TYPE . FORWARDED > , reportID ) }
84
101
/>
85
102
) ;
86
103
}
0 commit comments