@@ -1901,6 +1901,7 @@ function getSendInvoiceInformation(
1901
1901
currency ,
1902
1902
optimisticInvoiceReport . reportID ,
1903
1903
trimmedComment ,
1904
+ [ ] ,
1904
1905
created ,
1905
1906
'' ,
1906
1907
'' ,
@@ -2022,6 +2023,7 @@ function getMoneyRequestInformation(
2022
2023
payeeEmail = currentUserEmail ,
2023
2024
moneyRequestReportID = '' ,
2024
2025
linkedTrackedExpenseReportAction ?: OnyxTypes . ReportAction ,
2026
+ attendees ?: Attendee [ ] ,
2025
2027
) : MoneyRequestInformation {
2026
2028
const payerEmail = PhoneNumber . addSMSDomainIfPhoneNumber ( participant . login ?? '' ) ;
2027
2029
const payerAccountID = Number ( participant . accountID ) ;
@@ -2081,6 +2083,7 @@ function getMoneyRequestInformation(
2081
2083
currency ,
2082
2084
iouReport . reportID ,
2083
2085
comment ,
2086
+ attendees ,
2084
2087
created ,
2085
2088
'' ,
2086
2089
'' ,
@@ -2318,6 +2321,7 @@ function getTrackExpenseInformation(
2318
2321
currency ,
2319
2322
shouldUseMoneyReport && iouReport ? iouReport . reportID : '-1' ,
2320
2323
comment ,
2324
+ [ ] ,
2321
2325
created ,
2322
2326
'' ,
2323
2327
'' ,
@@ -2478,6 +2482,7 @@ function getUpdateMoneyRequestParams(
2478
2482
policyTagList : OnyxTypes . OnyxInputOrEntry < OnyxTypes . PolicyTagLists > ,
2479
2483
policyCategories : OnyxTypes . OnyxInputOrEntry < OnyxTypes . PolicyCategories > ,
2480
2484
onlyIncludeChangedFields : boolean ,
2485
+ violations ?: OnyxEntry < OnyxTypes . TransactionViolations > ,
2481
2486
) : UpdateMoneyRequestData {
2482
2487
const optimisticData : OnyxUpdate [ ] = [ ] ;
2483
2488
const successData : OnyxUpdate [ ] = [ ] ;
@@ -2721,7 +2726,19 @@ function getUpdateMoneyRequestParams(
2721
2726
}
2722
2727
}
2723
2728
2724
- // Clear out the error fields and loading states on success
2729
+ const overLimitViolation = violations ?. find ( ( violation ) => violation . name === 'overLimit' ) ;
2730
+ // Update violation limit, if we modify attendees. The given limit value is for a single attendee, if we have multiple attendees we should multpiply limit by attende count
2731
+ if ( 'attendees' in transactionChanges && ! ! overLimitViolation ) {
2732
+ const limitForSingleAttendee = ViolationsUtils . getViolationAmountLimit ( overLimitViolation ) ;
2733
+ if ( limitForSingleAttendee * ( transactionChanges ?. attendees ?. length ?? 1 ) > Math . abs ( TransactionUtils . getAmount ( transaction ) ) ) {
2734
+ optimisticData . push ( {
2735
+ onyxMethod : Onyx . METHOD . MERGE ,
2736
+ key : `${ ONYXKEYS . COLLECTION . TRANSACTION_VIOLATIONS } ${ transactionID } ` ,
2737
+ value : violations ?. filter ( ( violation ) => violation . name !== 'overLimit' ) ?? [ ] ,
2738
+ } ) ;
2739
+ }
2740
+ }
2741
+
2725
2742
successData . push ( {
2726
2743
onyxMethod : Onyx . METHOD . MERGE ,
2727
2744
key : `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` ,
@@ -3045,11 +3062,12 @@ function updateMoneyRequestAttendees(
3045
3062
policy : OnyxEntry < OnyxTypes . Policy > ,
3046
3063
policyTagList : OnyxEntry < OnyxTypes . PolicyTagLists > ,
3047
3064
policyCategories : OnyxEntry < OnyxTypes . PolicyCategories > ,
3065
+ violations : OnyxEntry < OnyxTypes . TransactionViolations > ,
3048
3066
) {
3049
3067
const transactionChanges : TransactionChanges = {
3050
3068
attendees,
3051
3069
} ;
3052
- const data = getUpdateMoneyRequestParams ( transactionID , transactionThreadReportID , transactionChanges , policy , policyTagList , policyCategories , true ) ;
3070
+ const data = getUpdateMoneyRequestParams ( transactionID , transactionThreadReportID , transactionChanges , policy , policyTagList , policyCategories , true , violations ) ;
3053
3071
const { params, onyxData} = data ;
3054
3072
API . write ( WRITE_COMMANDS . UPDATE_MONEY_REQUEST_ATTENDEES , params , onyxData ) ;
3055
3073
}
@@ -3572,6 +3590,7 @@ function requestMoney(
3572
3590
payeeEmail ,
3573
3591
moneyRequestReportID ,
3574
3592
linkedTrackedExpenseReportAction ,
3593
+ attendees ,
3575
3594
) ;
3576
3595
const activeReportID = isMoneyRequestReport ? report ?. reportID : chatReport . reportID ;
3577
3596
@@ -3980,6 +3999,7 @@ function createSplitsAndOnyxData(
3980
3999
currency ,
3981
4000
CONST . REPORT . SPLIT_REPORTID ,
3982
4001
comment ,
4002
+ [ ] ,
3983
4003
created ,
3984
4004
'' ,
3985
4005
'' ,
@@ -4217,6 +4237,7 @@ function createSplitsAndOnyxData(
4217
4237
currency ,
4218
4238
oneOnOneIOUReport . reportID ,
4219
4239
comment ,
4240
+ [ ] ,
4220
4241
created ,
4221
4242
CONST . IOU . TYPE . SPLIT ,
4222
4243
splitTransaction . transactionID ,
@@ -4564,6 +4585,7 @@ function startSplitBill({
4564
4585
currency ,
4565
4586
CONST . REPORT . SPLIT_REPORTID ,
4566
4587
comment ,
4588
+ [ ] ,
4567
4589
'' ,
4568
4590
'' ,
4569
4591
'' ,
@@ -4970,6 +4992,7 @@ function completeSplitBill(chatReportID: string, reportAction: OnyxTypes.ReportA
4970
4992
currency ?? '' ,
4971
4993
oneOnOneIOUReport ?. reportID ?? '-1' ,
4972
4994
updatedTransaction ?. comment ?. comment ,
4995
+ [ ] ,
4973
4996
updatedTransaction ?. modifiedCreated ,
4974
4997
CONST . IOU . TYPE . SPLIT ,
4975
4998
transactionID ,
0 commit comments