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 13 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 @@ -252,6 +252,7 @@ const ONYXKEYS = {
REPORT_USER_IS_LEAVING_ROOM: 'reportUserIsLeavingRoom_',
SECURITY_GROUP: 'securityGroup_',
TRANSACTION: 'transactions_',
DRAFT_SPLIT_TRANSACTION: 'draftSplitTransaction_',

// Manual request tab selector
SELECTED_TAB: 'selectedTab_',
Expand Down
8 changes: 8 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,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: number, reportActionID: number, 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: number, reportActionID: number, currency: string, backTo: string) => `r/${reportID}/split/${reportActionID}/edit/currency?currency=${currency}&backTo=${backTo}`,
},
youssef-lr marked this conversation as resolved.
Show resolved Hide resolved
TASK_TITLE: {
route: 'r/:reportID/title',
getRoute: (reportID: string) => `r/${reportID}/title`,
Expand Down
57 changes: 42 additions & 15 deletions src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ const propTypes = {
/** Whether the receipt associated with this report is being scanned */
isScanning: PropTypes.bool,

/** Whether we should show the amount, date, and merchant fields. */
shouldShowSmartScanFields: PropTypes.bool,

/** A flag for verifying that the current report is a sub-report of a workspace chat */
isPolicyExpenseChat: PropTypes.bool,

Expand Down Expand Up @@ -183,6 +186,7 @@ const defaultProps = {
mileageRate: {unit: CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES, rate: 0, currency: 'USD'},
isDistanceRequest: false,
isScanning: false,
shouldShowSmartScanFields: true,
isPolicyExpenseChat: false,
};

Expand All @@ -201,13 +205,9 @@ function MoneyRequestConfirmationList(props) {
// A flag for showing the categories field
const shouldShowCategories = props.isPolicyExpenseChat && Permissions.canUseCategories(props.betas) && OptionsListUtils.hasEnabledOptions(_.values(props.policyCategories));

// A flag for showing SmartScan fields: date, merchant, and amount, only when we don't have a receiptPath (e.g. manual request)
// or in the split details page which is ReadOnly
const shouldShowSmartScanFields = (!props.receiptPath || props.isReadOnly) && !props.isScanning;

// A flag and a toggler for showing the rest of the form fields
const [shouldExpandFields, toggleShouldExpandFields] = useReducer((state) => !state, false);
const shouldShowAllFields = props.isDistanceRequest || shouldExpandFields || !shouldShowSmartScanFields;
const shouldShowAllFields = props.isDistanceRequest || shouldExpandFields || !props.shouldShowSmartScanFields;

// Fetches the first tag list of the policy
const policyTag = PolicyUtils.getTag(props.policyTags);
Expand Down Expand Up @@ -266,9 +266,9 @@ function MoneyRequestConfirmationList(props) {

const splitOrRequestOptions = useMemo(() => {
let text;
if (props.receiptPath && props.hasMultipleParticipants && props.iouAmount === 0) {
if (props.receiptPath && props.hasMultipleParticipants && props.isScanning && props.iouAmount === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we are adding the isScanning condition? It's causing a regression

Screenshot 2023-10-10 at 10 28 56 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make the title relays solely on the iouType (instead of hasMultipleParticipants) and receiptPath

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks!

text = translate('iou.split');
} else if (props.receiptPath || isDistanceRequestWithoutRoute) {
} else if ((props.receiptPath && props.iouType === CONST.IOU.MONEY_REQUEST_TYPE.REQUEST) || isDistanceRequestWithoutRoute) {
text = translate('iou.request');
} else {
const translationKey = props.hasMultipleParticipants ? 'iou.splitAmount' : 'iou.requestAmount';
Expand All @@ -280,7 +280,7 @@ function MoneyRequestConfirmationList(props) {
value: props.hasMultipleParticipants ? CONST.IOU.MONEY_REQUEST_TYPE.SPLIT : CONST.IOU.MONEY_REQUEST_TYPE.REQUEST,
},
];
}, [props.hasMultipleParticipants, props.iouAmount, props.receiptPath, translate, formattedAmount, isDistanceRequestWithoutRoute]);
}, [props.hasMultipleParticipants, props.iouType, props.iouAmount, props.receiptPath, props.isScanning, translate, formattedAmount, isDistanceRequestWithoutRoute]);

const selectedParticipants = useMemo(() => _.filter(props.selectedParticipants, (participant) => participant.selected), [props.selectedParticipants]);
const payeePersonalDetails = useMemo(() => props.payeePersonalDetails || props.currentUserPersonalDetails, [props.payeePersonalDetails, props.currentUserPersonalDetails]);
Expand Down Expand Up @@ -508,12 +508,21 @@ function MoneyRequestConfirmationList(props) {
isAuthTokenRequired={!_.isEmpty(receiptThumbnail)}
/>
)}
{shouldShowSmartScanFields && (
{props.shouldShowSmartScanFields && (
<MenuItemWithTopDescription
shouldShowRightIcon={!props.isReadOnly && !props.isDistanceRequest}
title={formattedAmount}
description={translate('iou.amount')}
onPress={() => !props.isDistanceRequest && Navigation.navigate(ROUTES.MONEY_REQUEST_AMOUNT.getRoute(props.iouType, props.reportID))}
onPress={() => {
if (props.isDistanceRequest) {
return;
}
if (props.isEdittingSplitBill) {
Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(props.reportID, props.reportActionID, CONST.EDIT_REQUEST_FIELD.AMOUNT));
return;
}
Navigation.navigate(ROUTES.MONEY_REQUEST_AMOUNT.getRoute(props.iouType, props.reportID));
}}
style={[styles.moneyRequestMenuItem, styles.mt2]}
titleStyle={styles.moneyRequestConfirmationAmount}
disabled={didConfirm || props.isReadOnly}
Expand All @@ -524,7 +533,13 @@ function MoneyRequestConfirmationList(props) {
shouldParseTitle
title={props.iouComment}
description={translate('common.description')}
onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_DESCRIPTION.getRoute(props.iouType, props.reportID))}
onPress={() => {
if (props.isEdittingSplitBill) {
Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(props.reportID, props.reportActionID, CONST.EDIT_REQUEST_FIELD.DESCRIPTION));
return;
}
Navigation.navigate(ROUTES.MONEY_REQUEST_DESCRIPTION.getRoute(props.iouType, props.reportID));
}}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
disabled={didConfirm || props.isReadOnly}
Expand All @@ -547,14 +562,20 @@ function MoneyRequestConfirmationList(props) {
)}
{shouldShowAllFields && (
<>
{shouldShowSmartScanFields && (
{props.shouldShowSmartScanFields && (
<MenuItemWithTopDescription
shouldShowRightIcon={!props.isReadOnly && isTypeRequest}
title={props.iouCreated || format(new Date(), CONST.DATE.FNS_FORMAT_STRING)}
description={translate('common.date')}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_DATE.getRoute(props.iouType, props.reportID))}
onPress={() => {
if (props.isEdittingSplitBill) {
Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(props.reportID, props.reportActionID, CONST.EDIT_REQUEST_FIELD.DATE));
return;
}
Navigation.navigate(ROUTES.MONEY_REQUEST_DATE.getRoute(props.iouType, props.reportID));
}}
disabled={didConfirm || props.isReadOnly}
/>
)}
Expand All @@ -569,14 +590,20 @@ function MoneyRequestConfirmationList(props) {
disabled={didConfirm || props.isReadOnly || !isTypeRequest}
/>
)}
{shouldShowSmartScanFields && (
{props.shouldShowSmartScanFields && (
<MenuItemWithTopDescription
shouldShowRightIcon={!props.isReadOnly && isTypeRequest}
title={props.iouMerchant}
description={translate('common.merchant')}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_MERCHANT.getRoute(props.iouType, props.reportID))}
onPress={() => {
if (props.isEdittingSplitBill) {
Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(props.reportID, props.reportActionID, CONST.EDIT_REQUEST_FIELD.MERCHANT));
return;
}
Navigation.navigate(ROUTES.MONEY_REQUEST_MERCHANT.getRoute(props.iouType, props.reportID));
}}
disabled={didConfirm || props.isReadOnly}
/>
)}
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 @@ -344,6 +344,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
10 changes: 8 additions & 2 deletions src/libs/TransactionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
/**
* 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: boolean = true): Transaction {

Check failure on line 99 in src/libs/TransactionUtils.ts

View workflow job for this annotation

GitHub Actions / lint

Type boolean trivially inferred from a boolean literal, remove type annotation
youssef-lr marked this conversation as resolved.
Show resolved Hide resolved
// Only changing the first level fields so no need for deep clone now
const updatedTransaction = {...transaction};
let shouldStopSmartscan = false;
Expand Down Expand Up @@ -143,7 +143,13 @@
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
120 changes: 120 additions & 0 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,27 @@
},
});

let allDraftSplitTransactions;
Onyx.connect({
key: ONYXKEYS.COLLECTION.DRAFT_SPLIT_TRANSACTION,
waitForCollectionCallback: true,
callback: (val) => {
if (!val) {
allDraftSplitTransactions = {};
return;
}

allDraftSplitTransactions = val;
},
youssef-lr marked this conversation as resolved.
Show resolved Hide resolved
});

let allRecentlyUsedCategories = {};

Check failure on line 70 in src/libs/actions/IOU.js

View workflow job for this annotation

GitHub Actions / lint

'allRecentlyUsedCategories' is assigned a value but never used
Onyx.connect({
key: ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_CATEGORIES,
waitForCollectionCallback: true,
callback: (val) => (allRecentlyUsedCategories = val),
});

let allRecentlyUsedTags = {};
Onyx.connect({
key: ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS,
Expand Down Expand Up @@ -1481,6 +1502,103 @@
Report.notifyNewAction(splitChatReport.chatReportID, currentUserAccountID);
}

function completeSplitBill(chatReportID, reportAction, updatedTransaction, currentUserAccountID, currentUserEmail) {

Check failure on line 1505 in src/libs/actions/IOU.js

View workflow job for this annotation

GitHub Actions / lint

'currentUserEmail' is already declared in the upper scope on line 106 column 5
// Save optimistic updated transaction and action
const optimisticData = [

Check failure on line 1507 in src/libs/actions/IOU.js

View workflow job for this annotation

GitHub Actions / lint

'optimisticData' is assigned a value but never used
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${updatedTransaction.transactionID}`,
value: updatedTransaction,
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReportID}`,
value: {
[reportActionID]: {

Check failure on line 1517 in src/libs/actions/IOU.js

View workflow job for this annotation

GitHub Actions / lint

'reportActionID' is not defined
...reportAction,
lastModified: DateUtils.getDBTime(),
whisperedToAccountIDs: [],
},
},
},
];

const splitParticipants = transaction.comment.splits;

Check failure on line 1526 in src/libs/actions/IOU.js

View workflow job for this annotation

GitHub Actions / lint

'transaction' is not defined
const {modifiedAmount: amount, modifiedCurrency: currency} = splitTransaction;

Check failure on line 1527 in src/libs/actions/IOU.js

View workflow job for this annotation

GitHub Actions / lint

'splitTransaction' is not defined
const splitAmount = IOUUtils.calculateAmount(splitParticipants.length, amount, currency, false);
const splits = [];

Check failure on line 1529 in src/libs/actions/IOU.js

View workflow job for this annotation

GitHub Actions / lint

'splits' is assigned a value but never used
_.eacch(splitParticipants, (participant) => {
// Skip creating the transaction for the current user
if (participant.email && participant.email === currentUserEmail) {
return;
}
youssef-lr marked this conversation as resolved.
Show resolved Hide resolved
const isPolicyExpenseChat = !_.isEmpty(participant.policyID);
let oneOnOneChatReport;
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 {
oneOnOneChatReport = ReportUtils.getChatByParticipants([participant.accountID] || 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, currentUserAccountID, splitAmount, currency)
: ReportUtils.buildOptimisticIOUReport(currentUserAccountID, participant.accountID, splitAmount, oneOnOneChatReport.reportID, currency);
} else if (isOwnPolicyExpenseChat) {

Check failure on line 1552 in src/libs/actions/IOU.js

View workflow job for this annotation

GitHub Actions / lint

'isOwnPolicyExpenseChat' is not defined
// 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, currentUserAccountID, splitAmount, currency);
}

const oneOnOneTransaction = TransactionUtils.buildOptimisticTransaction(
isPolicyExpenseChat ? -splitAmount : splitAmount,
currency,
oneOnOneIOUReport.reportID,
updatedTransaction.comment,
youssef-lr marked this conversation as resolved.
Show resolved Hide resolved
'',
CONST.IOU.MONEY_REQUEST_TYPE.SPLIT,
updatedTransaction.transactionID,
);

const oneOnOneCreatedActionForChat = ReportUtils.buildOptimisticCreatedReportAction(currentUserEmailForIOUSplit);

Check failure on line 1569 in src/libs/actions/IOU.js

View workflow job for this annotation

GitHub Actions / lint

'oneOnOneCreatedActionForChat' is assigned a value but never used
const oneOnOneCreatedActionForIOU = ReportUtils.buildOptimisticCreatedReportAction(currentUserEmailForIOUSplit);
const oneOnOneIOUAction = ReportUtils.buildOptimisticIOUReportAction(
CONST.IOU.REPORT_ACTION_TYPE.CREATE,
splitAmount,
currency,
comment,
[participant],
oneOnOneTransaction.transactionID,
'',
oneOnOneIOUReport.reportID,
);
});

// Loop over participants and generate optimistic 1on1 chats and IOU reports, if workspace chat, generate optimistic expense report
}

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

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

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

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

/**
* @param {String} transactionID
* @param {Number} transactionThreadReportID
Expand Down Expand Up @@ -2629,7 +2747,9 @@
deleteMoneyRequest,
splitBill,
splitBillAndOpenReport,
setDraftSplitTransaction,
startSplitBill,
completeSplitBill,
requestMoney,
sendMoneyElsewhere,
approveMoneyRequest,
Expand Down
3 changes: 1 addition & 2 deletions src/pages/EditRequestAmountPage.js
Copy link
Contributor

Choose a reason for hiding this comment

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

Revert?

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const propTypes = {
reportID: PropTypes.string.isRequired,
};

function EditRequestAmountPage({defaultAmount, defaultCurrency, onSubmit, reportID}) {
function EditRequestAmountPage({defaultAmount, defaultCurrency, reportID, reportActionID, onSubmit}) {
const {translate} = useLocalize();
const textInput = useRef(null);

Expand All @@ -35,7 +35,6 @@ function EditRequestAmountPage({defaultAmount, defaultCurrency, onSubmit, report
if (!textInput.current) {
return;
}

textInput.current.focus();
});
};
Expand Down
Loading
Loading