22import { useNavigation } from '@react-navigation/native' ;
33import { deepEqual } from 'fast-equals' ;
44import mapValues from 'lodash/mapValues' ;
5- import React , { memo , use , useCallback , useContext , useEffect , useMemo , useRef , useState } from 'react' ;
5+ import React , { memo , useCallback , useContext , useEffect , useMemo , useRef , useState } from 'react' ;
66import type { GestureResponderEvent , TextInput } from 'react-native' ;
77import { Keyboard , View } from 'react-native' ;
88import type { OnyxEntry } from 'react-native-onyx' ;
9- import type { ValueOf } from 'type-fest' ;
109import * as ActionSheetAwareScrollView from '@components/ActionSheetAwareScrollView' ;
1110import Hoverable from '@components/Hoverable' ;
1211import InlineSystemMessage from '@components/InlineSystemMessage' ;
@@ -27,7 +26,6 @@ import TaskAction from '@components/ReportActionItem/TaskAction';
2726import TaskPreview from '@components/ReportActionItem/TaskPreview' ;
2827import TripRoomPreview from '@components/ReportActionItem/TripRoomPreview' ;
2928import UnreportedTransactionAction from '@components/ReportActionItem/UnreportedTransactionAction' ;
30- import { SearchStateContext } from '@components/Search/SearchContext' ;
3129import { useIsOnSearch } from '@components/Search/SearchScopeProvider' ;
3230import { ShowContextMenuActionsContext , ShowContextMenuStateContext } from '@components/ShowContextMenuContext' ;
3331import UnreadActionIndicator from '@components/UnreadActionIndicator' ;
@@ -94,6 +92,7 @@ import {
9492import {
9593 canWriteInReport ,
9694 getMovedActionMessage ,
95+ getTransactionsWithReceipts ,
9796 isCompletedTaskReport ,
9897 isExpenseReport ,
9998 isHarvestCreatedExpenseReport as isHarvestCreatedExpenseReportUtils ,
@@ -103,9 +102,10 @@ import {
103102import SelectionScraper from '@libs/SelectionScraper' ;
104103import { ReactionListContext } from '@pages/inbox/ReportScreenContext' ;
105104import AttachmentModalContext from '@pages/media/AttachmentModalScreen/AttachmentModalContext' ;
106- import type { IgnoreDirection } from '@userActions/ClearReportActionErrors' ;
105+ import { clearAllRelatedReportActionErrors } from '@userActions/ClearReportActionErrors' ;
107106import { hideEmojiPicker , isActive } from '@userActions/EmojiPickerAction' ;
108107import { expandURLPreview } from '@userActions/Report' ;
108+ import { clearError } from '@userActions/Transaction' ;
109109import CONST from '@src/CONST' ;
110110import ONYXKEYS from '@src/ONYXKEYS' ;
111111import type SCREENS from '@src/SCREENS' ;
@@ -219,41 +219,9 @@ type PureReportActionItemProps = {
219219 /** Whether the room is a chronos report */
220220 isChronosReport ?: boolean ;
221221
222- /** Function to resolve actionable report mention whisper */
223- resolveActionableReportMentionWhisper ?: (
224- report : OnyxEntry < OnyxTypes . Report > ,
225- reportAction : OnyxEntry < OnyxTypes . ReportAction > ,
226- resolution : ValueOf < typeof CONST . REPORT . ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION > ,
227- isReportArchived ?: boolean ,
228- ) => void ;
229-
230- /** Function to resolve actionable mention whisper */
231- resolveActionableMentionWhisper ?: (
232- report : OnyxEntry < OnyxTypes . Report > ,
233- reportAction : OnyxEntry < OnyxTypes . ReportAction > ,
234- resolution : ValueOf < typeof CONST . REPORT . ACTIONABLE_MENTION_WHISPER_RESOLUTION > ,
235- isReportArchived : boolean ,
236- parentReport ?: OnyxEntry < OnyxTypes . Report > ,
237- ) => void ;
238-
239222 /** Whether the provided report is a closed expense report with no expenses */
240223 isClosedExpenseReportWithNoExpenses ?: boolean ;
241224
242- /** Gets all transactions on an IOU report with a receipt */
243- getTransactionsWithReceipts ?: ( iouReportID : string | undefined ) => OnyxTypes . Transaction [ ] ;
244-
245- /** Function to clear an error from a transaction */
246- clearError ?: ( transactionID : string ) => void ;
247-
248- /** Function to clear all errors from a report action */
249- clearAllRelatedReportActionErrors ?: (
250- reportID : string | undefined ,
251- reportAction : OnyxTypes . ReportAction | null | undefined ,
252- originalReportID : string | undefined ,
253- ignore ?: IgnoreDirection ,
254- keys ?: string [ ] ,
255- ) => void ;
256-
257225 /** User payment card ID */
258226 userBillingFundID ?: number ;
259227
@@ -304,12 +272,7 @@ function PureReportActionItem({
304272 deleteReportActionDraft = ( ) => { } ,
305273 isArchivedRoom,
306274 isChronosReport,
307- resolveActionableReportMentionWhisper = ( ) => { } ,
308- resolveActionableMentionWhisper = ( ) => { } ,
309275 isClosedExpenseReportWithNoExpenses,
310- getTransactionsWithReceipts = ( ) => [ ] ,
311- clearError = ( ) => { } ,
312- clearAllRelatedReportActionErrors = ( ) => { } ,
313276 userBillingFundID,
314277 shouldShowBorder,
315278 shouldHighlight = false ,
@@ -333,7 +296,6 @@ function PureReportActionItem({
333296 const [ isPaymentMethodPopoverActive , setIsPaymentMethodPopoverActive ] = useState < boolean | undefined > ( ) ;
334297 const shouldRenderViewBasedOnAction = useTableReportViewActionRenderConditionals ( action ) ;
335298 const [ isHidden , setIsHidden ] = useState ( false ) ;
336- const [ moderationDecision , setModerationDecision ] = useState < OnyxTypes . DecisionName > ( CONST . MODERATION . MODERATOR_DECISION_APPROVED ) ;
337299 const { isActiveReportAction : isActiveReactionListReportAction , hideReactionList} = useContext ( ReactionListContext ) ;
338300 const { updateHiddenAttachments} = useContext ( AttachmentModalContext ) ;
339301 const composerTextInputRef = useRef < TextInput | HTMLTextAreaElement > ( null ) ;
@@ -372,11 +334,6 @@ function PureReportActionItem({
372334 ) ;
373335
374336 const isOnSearch = useIsOnSearch ( ) ;
375- let currentSearchHash : number | undefined ;
376- if ( isOnSearch ) {
377- const { currentSearchHash : searchContextCurrentSearchHash } = use ( SearchStateContext ) ;
378- currentSearchHash = searchContextCurrentSearchHash ;
379- }
380337
381338 const navigation = useNavigation < PlatformStackNavigationProp < ReportsSplitNavigatorParamList , typeof SCREENS . REPORT > > ( ) ;
382339 const dismissError = useCallback ( ( ) => {
@@ -392,7 +349,7 @@ function PureReportActionItem({
392349 clearError ( transactionID ) ;
393350 }
394351 clearAllRelatedReportActionErrors ( reportID , action , originalReportID ) ;
395- } , [ action , isSendingMoney , reportID , clearAllRelatedReportActionErrors , originalReportID , isReportActionLinked , report , chatReport , clearError , navigation ] ) ;
352+ } , [ action , isSendingMoney , reportID , originalReportID , isReportActionLinked , report , chatReport , navigation ] ) ;
396353
397354 const showDismissReceiptErrorModal = useCallback ( async ( ) => {
398355 const result = await showConfirmModal ( {
@@ -487,12 +444,10 @@ function PureReportActionItem({
487444
488445 // Hide reveal message button and show the message if latestDecision is changed to empty
489446 if ( ! latestDecision ) {
490- setModerationDecision ( CONST . MODERATION . MODERATOR_DECISION_APPROVED ) ;
491447 setIsHidden ( false ) ;
492448 return ;
493449 }
494450
495- setModerationDecision ( latestDecision ) ;
496451 if ( ! [ CONST . MODERATION . MODERATOR_DECISION_APPROVED , CONST . MODERATION . MODERATOR_DECISION_PENDING ] . some ( ( item ) => item === latestDecision ) && ! isPendingRemove ( action ) ) {
497452 setIsHidden ( true ) ;
498453 return ;
@@ -841,7 +796,6 @@ function PureReportActionItem({
841796 report = { report }
842797 originalReport = { originalReport }
843798 originalReportID = { originalReportID }
844- resolveActionableMentionWhisper = { resolveActionableMentionWhisper }
845799 />
846800 ) ;
847801 } else if ( isActionableReportMentionWhisper ( action ) ) {
@@ -852,7 +806,6 @@ function PureReportActionItem({
852806 report = { report }
853807 originalReport = { originalReport }
854808 isReportArchived = { isReportArchived }
855- resolveActionableReportMentionWhisper = { resolveActionableReportMentionWhisper }
856809 />
857810 ) ;
858811 } else if ( isActionableMentionInviteToSubmitExpenseConfirmWhisper ( action ) ) {
@@ -931,12 +884,10 @@ function PureReportActionItem({
931884 draftMessage = { draftMessage }
932885 index = { index }
933886 isHidden = { isHidden }
934- moderationDecision = { moderationDecision }
935887 updateHiddenState = { updateHiddenState }
936888 isArchivedRoom = { isArchivedRoom }
937889 composerTextInputRef = { composerTextInputRef }
938890 isOnSearch = { isOnSearch }
939- currentSearchHash = { currentSearchHash }
940891 contextMenuStateValue = { contextMenuStateValue }
941892 contextMenuActionsValue = { contextMenuActionsValue }
942893 userBillingFundID = { userBillingFundID }
@@ -1024,9 +975,6 @@ function PureReportActionItem({
1024975 iouReport = { iouReport }
1025976 isHovered = { hovered || isContextMenuActive }
1026977 isActive = { isReportActionActive && ! isContextMenuActive }
1027- hasBeenFlagged = {
1028- ! [ CONST . MODERATION . MODERATOR_DECISION_APPROVED , CONST . MODERATION . MODERATOR_DECISION_PENDING ] . some ( ( item ) => item === moderationDecision ) && ! isPendingRemove ( action )
1029- }
1030978 >
1031979 { content }
1032980 </ ReportActionItemSingle >
@@ -1089,8 +1037,7 @@ function PureReportActionItem({
10891037 const whisperedTo = getWhisperedTo ( action ) ;
10901038
10911039 const iouReportID = isMoneyRequestAction ( action ) && getOriginalMessage ( action ) ?. IOUReportID ? getOriginalMessage ( action ) ?. IOUReportID ?. toString ( ) : undefined ;
1092- const transactionsWithReceipts = getTransactionsWithReceipts ( iouReportID ) ;
1093- const isWhisper = whisperedTo . length > 0 && transactionsWithReceipts . length === 0 ;
1040+ const isWhisper = whisperedTo . length > 0 && getTransactionsWithReceipts ( iouReportID ) . length === 0 ;
10941041
10951042 // Calculating accessibilityLabel for chat message with sender, date and time and the message content.
10961043 const displayName = getDisplayNameOrDefault ( personalDetails ?. [ action . actorAccountID ?? CONST . DEFAULT_NUMBER_ID ] ) ;
0 commit comments