Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow split actions to be edited and implement IOU action completeSplitBill #29064

Merged
merged 68 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
8c8d3ff
Make SplitBillDetailsPage editable when receipt is scanning or SS failed
youssef-lr Oct 8, 2023
12b9043
Only show SmartScan fields splitting manually or editting a split
youssef-lr Oct 8, 2023
7fba50a
Create EditSplitBillPage
youssef-lr Oct 8, 2023
bd7c4b2
Create routes for EditSplitBillPage
youssef-lr Oct 8, 2023
4b95154
Configure inputs on split details page and link them with routes
youssef-lr Oct 8, 2023
8f3f426
Save split transaction edits to a draft transaction
youssef-lr Oct 9, 2023
60bca0e
Cleanup
youssef-lr Oct 9, 2023
914985f
Add useCallback dep
youssef-lr Oct 9, 2023
b3c4a3e
Add proptype
youssef-lr Oct 9, 2023
d62883c
Fix code removed by mistake
youssef-lr Oct 9, 2023
08d7577
Bug fix and lint
youssef-lr Oct 9, 2023
f516e3b
wip
youssef-lr Oct 9, 2023
5812464
Merge branch 'youssef_startSplitBill' into youssef_completeSplitBill
youssef-lr Oct 9, 2023
7950ce7
Merge branch 'youssef_startSplitBill' into youssef_completeSplitBill
youssef-lr Oct 10, 2023
4096fe2
Remove deprecated method and use withOnyx
youssef-lr Oct 10, 2023
dd69105
Add completeSplitBill action
youssef-lr Oct 10, 2023
46b6398
Send necessary params to completeSplitBill
youssef-lr Oct 10, 2023
f134e3f
Show right icon next to all fields in split details
youssef-lr Oct 10, 2023
01d37b7
Fix a few bugs
youssef-lr Oct 10, 2023
f495a29
Merge branch 'main' into youssef_completeSplitBill
youssef-lr Oct 10, 2023
5ad7a0a
Cleanup
youssef-lr Oct 10, 2023
322e20f
Update src/libs/TransactionUtils.ts
youssef-lr Oct 10, 2023
11883ed
Add nagivation to editting currency route
youssef-lr Oct 10, 2023
20be465
Add success & failure data to original transaction
youssef-lr Oct 10, 2023
9311976
Merge branch 'youssef_completeSplitBill' of github.com:Expensify/App …
youssef-lr Oct 10, 2023
1e71502
Cleanup splitOrRequestOptions
youssef-lr Oct 11, 2023
e3dc941
Fix typo
youssef-lr Oct 11, 2023
45d90fb
Apply suggestions from code review
youssef-lr Oct 11, 2023
3231d67
Add failure data reverting changes made in optimistic data
youssef-lr Oct 11, 2023
cc9a41c
Fix typo
youssef-lr Oct 11, 2023
b87312d
Optimize retrieval of Onyx data
youssef-lr Oct 11, 2023
6a8de3f
Optimize Onyx data more
youssef-lr Oct 11, 2023
c25228c
Address comments
youssef-lr Oct 11, 2023
ba0174c
Trim merchant
youssef-lr Oct 11, 2023
4e54b1b
Always navigate back to split details
youssef-lr Oct 11, 2023
63733b2
Fix jerky animation (might be reverted not sure if this is okay)
youssef-lr Oct 11, 2023
a518d61
Show error fields next to missing fields
youssef-lr Oct 11, 2023
cdf376b
Linting
youssef-lr Oct 11, 2023
95dc96f
Remove testing code
youssef-lr Oct 11, 2023
cc00910
Lint
youssef-lr Oct 11, 2023
5aad7a8
Delete draft split transaction in success data
youssef-lr Oct 11, 2023
be6be0f
Display form error when SmartScan fails
youssef-lr Oct 11, 2023
b274a70
Merge branch 'main' into youssef_completeSplitBill
youssef-lr Oct 11, 2023
56dc410
Rename param
youssef-lr Oct 11, 2023
2f976ef
Include current user in splits
youssef-lr Oct 11, 2023
f80a658
Lint
youssef-lr Oct 11, 2023
6a28df3
Dismiss modal and notify users after completing split bill
youssef-lr Oct 11, 2023
1e21419
Update translations
youssef-lr Oct 11, 2023
c7b5482
Use existing timeout logic for focusing text input
youssef-lr Oct 11, 2023
26a7311
Display form error when completing split bill with missing fields
youssef-lr Oct 11, 2023
48d684b
Bug fix
youssef-lr Oct 11, 2023
362a1ae
Use areRequiredFieldsEmpty
youssef-lr Oct 11, 2023
f8484ae
Fix lint and change form error when user completes split bill
youssef-lr Oct 11, 2023
583a607
Display field errors next to missing smartscan fields when use confirms
youssef-lr Oct 11, 2023
bf021a5
Cleanup
youssef-lr Oct 11, 2023
5867982
Apply suggestions from code review
youssef-lr Oct 11, 2023
7a6f4b2
Revert change, should be handled in follow up clean up
youssef-lr Oct 11, 2023
a740150
Fix isScanning state to also check for required fields being empty
youssef-lr Oct 11, 2023
f73674d
Fix areRequiredFieldsEmpty to check for non existent modified fields
youssef-lr Oct 11, 2023
0126d5f
Use non-interactive style instead of disabled style
youssef-lr Oct 11, 2023
9107a5a
Merge branch 'main' into youssef_completeSplitBill
youssef-lr Oct 11, 2023
272fb9b
Merge branch 'main' into youssef_completeSplitBill
youssef-lr Oct 11, 2023
5cd7d9b
Fix MenuItem console warning and checking for modified amount
youssef-lr Oct 11, 2023
95b3b9f
Fix checking for modifiedAmount
youssef-lr Oct 11, 2023
7945675
Keep merchant error if it equal partial marchant (none)
youssef-lr Oct 11, 2023
ddc2214
Merge branch 'main' into youssef_completeSplitBill
mountiny Oct 11, 2023
1a51105
Fix console warning
mountiny Oct 11, 2023
69c0df9
resolve conflicts
luacmartins Oct 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ const ONYXKEYS = {
REPORT_USER_IS_LEAVING_ROOM: 'reportUserIsLeavingRoom_',
SECURITY_GROUP: 'securityGroup_',
TRANSACTION: 'transactions_',
SPLIT_TRANSACTION_DRAFT: 'splitTransactionDraft_',
PRIVATE_NOTES_DRAFT: 'privateNotesDraft_',

// Manual request tab selector
Expand Down
8 changes: 8 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ export default {
route: 'r/:reportID/split/:reportActionID',
getRoute: (reportID: string, reportActionID: string) => `r/${reportID}/split/${reportActionID}`,
},
EDIT_SPLIT_BILL: {
route: `r/:reportID/split/:reportActionID/edit/:field`,
getRoute: (reportID: string, reportActionID: string, field: ValueOf<typeof CONST.EDIT_REQUEST_FIELD>) => `r/${reportID}/split/${reportActionID}/edit/${field}`,
},
EDIT_SPLIT_BILL_CURRENCY: {
route: 'r/:reportID/split/:reportActionID/edit/currency',
getRoute: (reportID: string, reportActionID: string, currency: string, backTo: string) => `r/${reportID}/split/${reportActionID}/edit/currency?currency=${currency}&backTo=${backTo}`,
},
TASK_TITLE: {
route: 'r/:reportID/title',
getRoute: (reportID: string) => `r/${reportID}/title`,
Expand Down
155 changes: 122 additions & 33 deletions src/components/MoneyRequestConfirmationList.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ export default {
receiptMissingDetails: 'Receipt missing details',
receiptStatusTitle: 'Scanning…',
receiptStatusText: "Only you can see this receipt when it's scanning. Check back later or enter the details now.",
receiptScanningFailed: 'Receipt scanning failed. Enter the details manually.',
requestCount: ({count, scanningReceipts = 0}: RequestCountParams) => `${count} requests${scanningReceipts > 0 ? `, ${scanningReceipts} scanning` : ''}`,
deleteRequest: 'Delete request',
deleteConfirmation: 'Are you sure that you want to delete this request?',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ export default {
receiptMissingDetails: 'Recibo con campos vacíos',
receiptStatusTitle: 'Escaneando…',
receiptStatusText: 'Solo tú puedes ver este recibo cuando se está escaneando. Vuelve más tarde o introduce los detalles ahora.',
receiptScanningFailed: 'El escaneo de recibo ha fallado. Introduce los detalles manualmente.',
requestCount: ({count, scanningReceipts = 0}: RequestCountParams) => `${count} solicitudes${scanningReceipts > 0 ? `, ${scanningReceipts} escaneando` : ''}`,
deleteRequest: 'Eliminar pedido',
deleteConfirmation: '¿Estás seguro de que quieres eliminar este pedido?',
Expand Down
2 changes: 2 additions & 0 deletions src/libs/Navigation/AppNavigator/ModalStackNavigators.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ const MoneyRequestModalStackNavigator = createModalStackNavigator({

const SplitDetailsModalStackNavigator = createModalStackNavigator({
SplitDetails_Root: () => require('../../../pages/iou/SplitBillDetailsPage').default,
SplitDetails_Edit_Request: () => require('../../../pages/EditSplitBillPage').default,
SplitDetails_Edit_Currency: () => require('../../../pages/iou/IOUCurrencySelection').default,
});

const DetailsModalStackNavigator = createModalStackNavigator({
Expand Down
2 changes: 2 additions & 0 deletions src/libs/Navigation/linkingConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ export default {
SplitDetails: {
screens: {
SplitDetails_Root: ROUTES.SPLIT_BILL_DETAILS.route,
SplitDetails_Edit_Request: ROUTES.EDIT_SPLIT_BILL.route,
SplitDetails_Edit_Currency: ROUTES.EDIT_SPLIT_BILL_CURRENCY.route,
},
},
Task_Details: {
Expand Down
28 changes: 20 additions & 8 deletions src/libs/TransactionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,25 @@ function hasReceipt(transaction: Transaction | undefined | null): boolean {
}

function areRequiredFieldsEmpty(transaction: Transaction): boolean {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @luacmartins @mountiny can you guys check this change? areRequiredFieldsEmpty was returning false even tho we had a missing modifiedMerchant, because it doesn’t check for non existent modifiedMerchant in the object

return (
const isMerchantEmpty =
transaction.merchant === CONST.TRANSACTION.UNKNOWN_MERCHANT || transaction.merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT || transaction.merchant === '';

const isModifiedMerchantEmpty =
!transaction.modifiedMerchant ||
transaction.modifiedMerchant === CONST.TRANSACTION.UNKNOWN_MERCHANT ||
transaction.modifiedMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT ||
(transaction.modifiedMerchant === '' &&
(transaction.merchant === CONST.TRANSACTION.UNKNOWN_MERCHANT || transaction.merchant === '' || transaction.merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT)) ||
(transaction.modifiedAmount === 0 && transaction.amount === 0) ||
(transaction.modifiedCreated === '' && transaction.created === '')
);
transaction.modifiedMerchant === '';

const isModifiedAmountEmpty = !transaction.modifiedAmount || transaction.modifiedAmount === 0;
const isModifiedCreatedEmpty = !transaction.modifiedCreated || transaction.modifiedCreated === '';

return (isModifiedMerchantEmpty && isMerchantEmpty) || (isModifiedAmountEmpty && transaction.amount === 0) || (isModifiedCreatedEmpty && transaction.created === '');
}

/**
* Given the edit made to the money request, return an updated transaction object.
*/
function getUpdatedTransaction(transaction: Transaction, transactionChanges: TransactionChanges, isFromExpenseReport: boolean): Transaction {
function getUpdatedTransaction(transaction: Transaction, transactionChanges: TransactionChanges, isFromExpenseReport: boolean, shouldUpdateReceiptState = true): Transaction {
// Only changing the first level fields so no need for deep clone now
const updatedTransaction = {...transaction};
let shouldStopSmartscan = false;
Expand Down Expand Up @@ -144,7 +149,13 @@ function getUpdatedTransaction(transaction: Transaction, transactionChanges: Tra
updatedTransaction.tag = transactionChanges.tag;
}

if (shouldStopSmartscan && transaction?.receipt && Object.keys(transaction.receipt).length > 0 && transaction?.receipt?.state !== CONST.IOU.RECEIPT_STATE.OPEN) {
if (
shouldUpdateReceiptState &&
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this function handles updating a receipt, the function name is getUpdatedTransaction, but seems like the function has a side effect.

shouldStopSmartscan &&
transaction?.receipt &&
Object.keys(transaction.receipt).length > 0 &&
transaction?.receipt?.state !== CONST.IOU.RECEIPT_STATE.OPEN
) {
updatedTransaction.receipt.state = CONST.IOU.RECEIPT_STATE.OPEN;
}

Expand Down Expand Up @@ -438,6 +449,7 @@ export {
isPending,
isPosted,
getWaypoints,
areRequiredFieldsEmpty,
hasMissingSmartscanFields,
getWaypointIndex,
waypointHasValidAddress,
Expand Down
234 changes: 234 additions & 0 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ Onyx.connect({
},
});

let allDraftSplitTransactions;
Onyx.connect({
key: ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT,
waitForCollectionCallback: true,
callback: (val) => {
allDraftSplitTransactions = val || {};
},
});

let allRecentlyUsedTags = {};
Onyx.connect({
key: ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS,
Expand Down Expand Up @@ -1489,6 +1498,229 @@ function startSplitBill(participants, currentUserLogin, currentUserAccountID, co
Report.notifyNewAction(splitChatReport.chatReportID, currentUserAccountID);
}

/** Used for editing a split bill while it's still scanning or when SmartScan fails, it completes a split bill started by startSplitBill above.
*
* @param {number} chatReportID - The group chat or workspace reportID
* @param {Object} reportAction - The split action that lives in the chatReport above
* @param {Object} updatedTransaction - The updated **draft** split transaction
* @param {Number} sessionAccountID - accountID of the current user
* @param {String} sessionEmail - email of the current user
*/
function completeSplitBill(chatReportID, reportAction, updatedTransaction, sessionAccountID, sessionEmail) {
const currentUserEmailForIOUSplit = OptionsListUtils.addSMSDomainIfPhoneNumber(sessionEmail);
const {transactionID} = updatedTransaction;
const unmodifiedTransaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];

// Save optimistic updated transaction and action
const optimisticData = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: {
...updatedTransaction,
receipt: {
state: CONST.IOU.RECEIPT_STATE.OPEN,
},
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReportID}`,
value: {
[reportAction.reportActionID]: {
lastModified: DateUtils.getDBTime(),
whisperedToAccountIDs: [],
},
},
},
];

const successData = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: {pendingAction: null},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`,
value: null,
},
];

const failureData = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: {
...unmodifiedTransaction,
errors: ErrorUtils.getMicroSecondOnyxError('iou.error.genericCreateFailureMessage'),
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReportID}`,
value: {
[reportAction.reportActionID]: {
...reportAction,
errors: ErrorUtils.getMicroSecondOnyxError('iou.error.genericCreateFailureMessage'),
},
},
},
];

const splitParticipants = updatedTransaction.comment.splits;
const {modifiedAmount: amount, modifiedCurrency: currency} = updatedTransaction;

// Exclude the current user when calculating the split amount, `calculateAmount` takes it into account
const splitAmount = IOUUtils.calculateAmount(splitParticipants.length - 1, amount, currency, false);

const splits = [{email: currentUserEmailForIOUSplit}];
_.each(splitParticipants, (participant) => {
// Skip creating the transaction for the current user
if (participant.email === currentUserEmailForIOUSplit) {
return;
}
const isPolicyExpenseChat = !_.isEmpty(participant.policyID);

if (!isPolicyExpenseChat) {
// In case this is still the optimistic accountID saved in the splits array, return early as we cannot know
// if there is an existing chat between the split creator and this participant
// Instead, we will rely on Auth generating the report IDs and the user won't see any optimistic chats or reports created
const participantPersonalDetails = allPersonalDetails[participant.accountID] || {};
if (!participantPersonalDetails || participantPersonalDetails.isOptimisticPersonalDetail) {
splits.push({
email: participant.email,
});
youssef-lr marked this conversation as resolved.
Show resolved Hide resolved
return;
}
}

let oneOnOneChatReport;
let isNewOneOnOneChatReport = false;
if (isPolicyExpenseChat) {
// The workspace chat reportID is saved in the splits array when starting a split bill with a workspace
oneOnOneChatReport = allReports[`${ONYXKEYS.COLLECTION.REPORT}${participant.chatReportID}`];
} else {
const existingChatReport = ReportUtils.getChatByParticipants([participant.accountID]);
isNewOneOnOneChatReport = !existingChatReport;
oneOnOneChatReport = existingChatReport || ReportUtils.buildOptimisticChatReport([participant.accountID]);
}

let oneOnOneIOUReport = lodashGet(allReports, `${ONYXKEYS.COLLECTION.REPORT}${oneOnOneChatReport.iouReportID}`, undefined);
const shouldCreateNewOneOnOneIOUReport =
_.isUndefined(oneOnOneIOUReport) || (isPolicyExpenseChat && ReportUtils.isControlPolicyExpenseReport(oneOnOneIOUReport) && ReportUtils.isReportApproved(oneOnOneIOUReport));

if (shouldCreateNewOneOnOneIOUReport) {
oneOnOneIOUReport = isPolicyExpenseChat
? ReportUtils.buildOptimisticExpenseReport(oneOnOneChatReport.reportID, participant.policyID, sessionAccountID, splitAmount, currency)
: ReportUtils.buildOptimisticIOUReport(sessionAccountID, participant.accountID, splitAmount, oneOnOneChatReport.reportID, currency);
} else if (isPolicyExpenseChat) {
// Because of the Expense reports are stored as negative values, we subtract the total from the amount
oneOnOneIOUReport.total -= splitAmount;
} else {
oneOnOneIOUReport = IOUUtils.updateIOUOwnerAndTotal(oneOnOneIOUReport, sessionAccountID, splitAmount, currency);
}

const oneOnOneTransaction = TransactionUtils.buildOptimisticTransaction(
isPolicyExpenseChat ? -splitAmount : splitAmount,
currency,
oneOnOneIOUReport.reportID,
updatedTransaction.comment.comment,
updatedTransaction.modifiedCreated,
CONST.IOU.MONEY_REQUEST_TYPE.SPLIT,
transactionID,
updatedTransaction.modifiedMerchant,
{...updatedTransaction.receipt, state: CONST.IOU.RECEIPT_STATE.OPEN},
updatedTransaction.filename,
);

const oneOnOneCreatedActionForChat = ReportUtils.buildOptimisticCreatedReportAction(currentUserEmailForIOUSplit);
const oneOnOneCreatedActionForIOU = ReportUtils.buildOptimisticCreatedReportAction(currentUserEmailForIOUSplit);
const oneOnOneIOUAction = ReportUtils.buildOptimisticIOUReportAction(
CONST.IOU.REPORT_ACTION_TYPE.CREATE,
splitAmount,
currency,
updatedTransaction.comment.comment,
[participant],
oneOnOneTransaction.transactionID,
'',
oneOnOneIOUReport.reportID,
);

let oneOnOneReportPreviewAction = ReportActionsUtils.getReportPreviewAction(oneOnOneChatReport.reportID, oneOnOneIOUReport.reportID);
if (oneOnOneReportPreviewAction) {
oneOnOneReportPreviewAction = ReportUtils.updateReportPreview(oneOnOneIOUReport, oneOnOneReportPreviewAction);
} else {
oneOnOneReportPreviewAction = ReportUtils.buildOptimisticReportPreview(oneOnOneChatReport, oneOnOneIOUReport, '', oneOnOneTransaction);
}

const [oneOnOneOptimisticData, oneOnOneSuccessData, oneOnOneFailureData] = buildOnyxDataForMoneyRequest(
oneOnOneChatReport,
oneOnOneIOUReport,
oneOnOneTransaction,
oneOnOneCreatedActionForChat,
oneOnOneCreatedActionForIOU,
oneOnOneIOUAction,
{},
oneOnOneReportPreviewAction,
{},
{},
isNewOneOnOneChatReport,
shouldCreateNewOneOnOneIOUReport,
);

splits.push({
email: participant.email,
accountID: participant.accountID,
youssef-lr marked this conversation as resolved.
Show resolved Hide resolved
policyID: participant.policyID,
iouReportID: oneOnOneIOUReport.reportID,
chatReportID: oneOnOneChatReport.reportID,
transactionID: oneOnOneTransaction.transactionID,
reportActionID: oneOnOneIOUAction.reportActionID,
createdChatReportActionID: oneOnOneCreatedActionForChat.reportActionID,
createdIOUReportActionID: oneOnOneCreatedActionForIOU.reportActionID,
reportPreviewReportActionID: oneOnOneReportPreviewAction.reportActionID,
});

optimisticData.push(...oneOnOneOptimisticData);
successData.push(...oneOnOneSuccessData);
failureData.push(...oneOnOneFailureData);
});

API.write(
'CompleteSplitBill',
{
transactionID,
amount: updatedTransaction.modifiedAmount,
currency: updatedTransaction.modifiedCurrency,
created: updatedTransaction.modifiedCreated,
merchant: updatedTransaction.modifiedMerchant,
comment: updatedTransaction.comment.comment,
splits: JSON.stringify(splits),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this is backend related but why we are not sending the data as is?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't stringify the object the backend ends up receiving [Object object] instead of the JSON object

},
{optimisticData, successData, failureData},
);
Navigation.dismissModal(chatReportID);
Report.notifyNewAction(chatReportID, sessionAccountID);
}

/**
* @param {String} transactionID
* @param {Object} transactionChanges
*/
function setDraftSplitTransaction(transactionID, transactionChanges = {}) {
let draftSplitTransaction = allDraftSplitTransactions[`${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`];

if (!draftSplitTransaction) {
draftSplitTransaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
}

const updatedTransaction = TransactionUtils.getUpdatedTransaction(draftSplitTransaction, transactionChanges, false, false);

Onyx.merge(`${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`, updatedTransaction);
}

/**
* @param {String} transactionID
* @param {Number} transactionThreadReportID
Expand Down Expand Up @@ -2660,7 +2892,9 @@ export {
deleteMoneyRequest,
splitBill,
splitBillAndOpenReport,
setDraftSplitTransaction,
startSplitBill,
completeSplitBill,
requestMoney,
sendMoneyElsewhere,
approveMoneyRequest,
Expand Down
Loading
Loading