@@ -210,7 +210,7 @@ import type {QuickActionName} from '@src/types/onyx/QuickAction';
210210import type { InvoiceReceiver , InvoiceReceiverType } from '@src/types/onyx/Report' ;
211211import type ReportAction from '@src/types/onyx/ReportAction' ;
212212import type { OnyxData } from '@src/types/onyx/Request' ;
213- import type { SearchDataTypes , SearchPolicy , SearchReport , SearchTransaction } from '@src/types/onyx/SearchResults' ;
213+ import type { SearchPolicy , SearchReport , SearchTransaction } from '@src/types/onyx/SearchResults' ;
214214import type { Comment , Receipt , ReceiptSource , Routes , SplitShares , TransactionChanges , TransactionCustomUnit , WaypointCollection } from '@src/types/onyx/Transaction' ;
215215import { isEmptyObject } from '@src/types/utils/EmptyObject' ;
216216import { clearByKey as clearPdfByOnyxKey } from './CachedPDFPaths' ;
@@ -645,6 +645,7 @@ type GetSearchOnyxUpdateParams = {
645645 transaction : OnyxTypes . Transaction ;
646646 participant ?: Participant ;
647647 iouReport ?: OnyxEntry < OnyxTypes . Report > ;
648+ isInvoice ?: boolean ;
648649 transactionThreadReportID : string | undefined ;
649650} ;
650651
@@ -2322,6 +2323,7 @@ function buildOnyxDataForInvoice(invoiceParams: BuildOnyxDataForInvoiceParams):
23222323 const searchUpdate = getSearchOnyxUpdate ( {
23232324 transaction,
23242325 participant,
2326+ isInvoice : true ,
23252327 transactionThreadReportID : transactionParams . threadReport . reportID ,
23262328 } ) ;
23272329
@@ -11267,15 +11269,15 @@ function resolveDuplicates(params: MergeDuplicatesParams) {
1126711269 API . write ( WRITE_COMMANDS . RESOLVE_DUPLICATES , parameters , { optimisticData, failureData} ) ;
1126811270}
1126911271
11270- function getSearchOnyxUpdate ( { participant, transaction, iouReport, transactionThreadReportID} : GetSearchOnyxUpdateParams ) : OnyxData | undefined {
11272+ function getSearchOnyxUpdate ( { participant, transaction, iouReport, transactionThreadReportID, isInvoice } : GetSearchOnyxUpdateParams ) : OnyxData | undefined {
1127111273 const toAccountID = participant ?. accountID ;
1127211274 const fromAccountID = currentUserPersonalDetails ?. accountID ;
1127311275 const currentSearchQueryJSON = getCurrentSearchQueryJSON ( ) ;
1127411276
1127511277 if ( currentSearchQueryJSON && toAccountID != null && fromAccountID != null ) {
11276- const validSearchTypes : SearchDataTypes [ ] = [ CONST . SEARCH . DATA_TYPES . EXPENSE , CONST . SEARCH . DATA_TYPES . INVOICE ] ;
11277- const shouldOptimisticallyUpdate =
11278- currentSearchQueryJSON . status === CONST . SEARCH . STATUS . EXPENSE . ALL && validSearchTypes . includes ( currentSearchQueryJSON . type ) && currentSearchQueryJSON . flatFilters . length === 0 ;
11278+ const validSearchTypes =
11279+ ( ! isInvoice && currentSearchQueryJSON . type === CONST . SEARCH . DATA_TYPES . EXPENSE ) || ( isInvoice && currentSearchQueryJSON . type === CONST . SEARCH . DATA_TYPES . INVOICE ) ;
11280+ const shouldOptimisticallyUpdate = currentSearchQueryJSON . status === CONST . SEARCH . STATUS . EXPENSE . ALL && validSearchTypes && currentSearchQueryJSON . flatFilters . length === 0 ;
1127911281
1128011282 if ( shouldOptimisticallyUpdate ) {
1128111283 const isOptimisticToAccountData = isOptimisticPersonalDetail ( toAccountID ) ;
0 commit comments