Skip to content

Commit

Permalink
fix: revert unnecessary iou changes
Browse files Browse the repository at this point in the history
  • Loading branch information
koko57 committed Feb 9, 2024
1 parent e3dde0e commit 205d6f2
Showing 1 changed file with 7 additions and 34 deletions.
41 changes: 7 additions & 34 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,7 @@ function clearMoneyRequest(transactionID: string) {
// eslint-disable-next-line @typescript-eslint/naming-convention
function setMoneyRequestAmount_temporaryForRefactor(transactionID: string, amount: number, currency: string, removeOriginalCurrency = false) {
if (removeOriginalCurrency) {
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {
amount,
currency,
originalCurrency: null,
});
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {amount, currency, originalCurrency: null});
return;
}
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {amount, currency});
Expand Down Expand Up @@ -361,11 +357,7 @@ function resetMoneyRequestInfo(id = '') {
function getReceiptError(receipt?: Receipt, filename?: string, isScanRequest = true): Errors | ErrorFields {
return isEmptyObject(receipt) || !isScanRequest
? ErrorUtils.getMicroSecondOnyxError('iou.error.genericCreateFailureMessage')
: ErrorUtils.getMicroSecondOnyxErrorObject({
error: CONST.IOU.RECEIPT_ERROR,
source: receipt.source?.toString() ?? '',
filename: filename ?? '',
});
: ErrorUtils.getMicroSecondOnyxErrorObject({error: CONST.IOU.RECEIPT_ERROR, source: receipt.source?.toString() ?? '', filename: filename ?? ''});
}

/** Return the object to update hasOutstandingChildRequest */
Expand Down Expand Up @@ -1571,13 +1563,7 @@ function createSplitsAndOnyxData(

// Loop through participants creating individual chats, iouReports and reportActionIDs as needed
const splitAmount = IOUUtils.calculateAmount(participants.length, amount, currency, false);
const splits: Split[] = [
{
email: currentUserEmailForIOUSplit,
accountID: currentUserAccountID,
amount: IOUUtils.calculateAmount(participants.length, amount, currency, true),
},
];
const splits: Split[] = [{email: currentUserEmailForIOUSplit, accountID: currentUserAccountID, amount: IOUUtils.calculateAmount(participants.length, amount, currency, true)}];

const hasMultipleParticipants = participants.length > 1;
participants.forEach((participant) => {
Expand Down Expand Up @@ -3593,17 +3579,9 @@ function setMoneyRequestParticipantsFromReport(transactionID: string, report: On
const currentUserAccountID = currentUserPersonalDetails.accountID;
const participants: Participant[] = ReportUtils.isPolicyExpenseChat(chatReport)
? [{reportID: chatReport?.reportID, isPolicyExpenseChat: true, selected: true}]
: (chatReport?.participantAccountIDs ?? [])
.filter((accountID) => currentUserAccountID !== accountID)
.map((accountID) => ({
accountID,
selected: true,
}));

Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {
participants,
participantsAutoAssigned: true,
});
: (chatReport?.participantAccountIDs ?? []).filter((accountID) => currentUserAccountID !== accountID).map((accountID) => ({accountID, selected: true}));

Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {participants, participantsAutoAssigned: true});
}

/** Initialize money request info and navigate to the MoneyRequest page */
Expand Down Expand Up @@ -3691,12 +3669,7 @@ function navigateToNextPage(iou: OnyxEntry<OnyxTypes.IOU>, iouType: string, repo
const currentUserAccountID = currentUserPersonalDetails.accountID;
const participants: Participant[] = ReportUtils.isPolicyExpenseChat(chatReport)
? [{reportID: chatReport?.reportID, isPolicyExpenseChat: true, selected: true}]
: (chatReport?.participantAccountIDs ?? [])
.filter((accountID) => currentUserAccountID !== accountID)
.map((accountID) => ({
accountID,
selected: true,
}));
: (chatReport?.participantAccountIDs ?? []).filter((accountID) => currentUserAccountID !== accountID).map((accountID) => ({accountID, selected: true}));
setMoneyRequestParticipants(participants);
resetMoneyRequestCategory();
}
Expand Down

0 comments on commit 205d6f2

Please sign in to comment.