@@ -3486,7 +3486,7 @@ function buildOptimisticRecentlyUsedCurrencies(currency?: string) {
34863486// eslint-disable-next-line rulesdir/no-call-actions-from-actions
34873487function createWorkspaceFromIOUPayment ( iouReport : OnyxEntry < Report > ) : WorkspaceFromIOUCreationData | undefined {
34883488 // This flow only works for IOU reports
3489- if ( ! ReportUtils . isIOUReportUsingReport ( iouReport ) ) {
3489+ if ( ! iouReport || ! ReportUtils . isIOUReportUsingReport ( iouReport ) ) {
34903490 return ;
34913491 }
34923492
@@ -3496,7 +3496,7 @@ function createWorkspaceFromIOUPayment(iouReport: OnyxEntry<Report>): WorkspaceF
34963496 const employeeAccountID = iouReport ?. ownerAccountID ;
34973497 const { customUnits, customUnitID, customUnitRateID} = buildOptimisticDistanceRateCustomUnits ( iouReport ?. currency ) ;
34983498 const oldPersonalPolicyID = iouReport ?. policyID ;
3499- const iouReportID = iouReport ?. reportID ?? '' ;
3499+ const iouReportID = iouReport ?. reportID ;
35003500
35013501 const {
35023502 adminsChatReportID,
@@ -3763,18 +3763,16 @@ function createWorkspaceFromIOUPayment(iouReport: OnyxEntry<Report>): WorkspaceF
37633763 type : CONST . REPORT . TYPE . EXPENSE ,
37643764 total : - ( iouReport ?. total ?? 0 ) ,
37653765 } ;
3766- if ( iouReport ) {
3767- optimisticData . push ( {
3768- onyxMethod : Onyx . METHOD . MERGE ,
3769- key : `${ ONYXKEYS . COLLECTION . REPORT } ${ iouReportID } ` ,
3770- value : expenseReport ,
3771- } ) ;
3772- failureData . push ( {
3773- onyxMethod : Onyx . METHOD . MERGE ,
3774- key : `${ ONYXKEYS . COLLECTION . REPORT } ${ iouReportID } ` ,
3775- value : iouReport ,
3776- } ) ;
3777- }
3766+ optimisticData . push ( {
3767+ onyxMethod : Onyx . METHOD . MERGE ,
3768+ key : `${ ONYXKEYS . COLLECTION . REPORT } ${ iouReportID } ` ,
3769+ value : expenseReport ,
3770+ } ) ;
3771+ failureData . push ( {
3772+ onyxMethod : Onyx . METHOD . MERGE ,
3773+ key : `${ ONYXKEYS . COLLECTION . REPORT } ${ iouReportID } ` ,
3774+ value : iouReport ,
3775+ } ) ;
37783776
37793777 // The expense report transactions need to have the amount reversed to negative values
37803778 const reportTransactions = ReportUtils . getReportTransactions ( iouReportID ) ;
0 commit comments