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 1 commit
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
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com>
  • Loading branch information
youssef-lr and s77rt authored Oct 11, 2023
commit 45d90fba9f605e9493146bbce8eaf5b5c82eed80
4 changes: 2 additions & 2 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ export default {
},
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}`,
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: number, reportActionID: number, currency: string, backTo: string) => `r/${reportID}/split/${reportActionID}/edit/currency?currency=${currency}&backTo=${backTo}`,
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',
Expand Down
13 changes: 4 additions & 9 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,11 @@
key: ONYXKEYS.COLLECTION.DRAFT_SPLIT_TRANSACTION,
waitForCollectionCallback: true,
callback: (val) => {
if (!val) {
allDraftSplitTransactions = {};
return;
}

allDraftSplitTransactions = val;
allDraftSplitTransactions = val || {};
},
});

let allRecentlyUsedCategories = {};

Check failure on line 65 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,
Expand Down Expand Up @@ -1510,7 +1505,7 @@
Report.notifyNewAction(splitChatReport.chatReportID, currentUserAccountID);
}

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

Check failure on line 1508 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 101 column 5
const currentUserEmailForIOUSplit = OptionsListUtils.addSMSDomainIfPhoneNumber(currentUserEmail);

// Save optimistic updated transaction and action
Expand Down Expand Up @@ -1564,7 +1559,7 @@
const splits = [];
_.each(splitParticipants, (participant) => {
// Skip creating the transaction for the current user
if (participant.email && participant.email === currentUserEmail) {
if (participant.email === currentUserEmailForIOUSplit) {
return;
}
const isPolicyExpenseChat = !_.isEmpty(participant.policyID);
Expand All @@ -1588,7 +1583,7 @@
// 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 {
let existingChatReport = ReportUtils.getChatByParticipants([participant.accountID]);

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

View workflow job for this annotation

GitHub Actions / lint

'existingChatReport' is never reassigned. Use 'const' instead
isNewOneOnOneChatReport = !existingChatReport;
oneOnOneChatReport = existingChatReport || ReportUtils.buildOptimisticChatReport([participant.accountID]);
}
Expand All @@ -1601,7 +1596,7 @@
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 1599 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 {
Expand All @@ -1612,7 +1607,7 @@
isPolicyExpenseChat ? -splitAmount : splitAmount,
currency,
oneOnOneIOUReport.reportID,
updatedTransaction.comment,
updatedTransaction.comment.comment,
updatedTransaction.modifiedCreated,
CONST.IOU.MONEY_REQUEST_TYPE.SPLIT,
updatedTransaction.transactionID,
Expand All @@ -1627,7 +1622,7 @@
CONST.IOU.REPORT_ACTION_TYPE.CREATE,
splitAmount,
currency,
updatedTransaction.modifiedComment,
updatedTransaction.comment.comment,
[participant],
oneOnOneTransaction.transactionID,
'',
Expand Down
6 changes: 3 additions & 3 deletions src/pages/EditSplitBillPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import PropTypes from 'prop-types';
import lodashGet from 'lodash/get';
import {withOnyx} from 'react-native-onyx';
import compose from '../libs/compose';

Check failure on line 5 in src/pages/EditSplitBillPage.js

View workflow job for this annotation

GitHub Actions / lint

'compose' is defined but never used
import CONST from '../CONST';
import ROUTES from '../ROUTES';
import Navigation from '../libs/Navigation/Navigation';
Expand All @@ -11,7 +11,7 @@
import transactionPropTypes from '../components/transactionPropTypes';
import * as ReportActionsUtils from '../libs/ReportActionsUtils';
import * as ReportUtils from '../libs/ReportUtils';
import * as TransactionUtils from '../libs/TransactionUtils';

Check failure on line 14 in src/pages/EditSplitBillPage.js

View workflow job for this annotation

GitHub Actions / lint

'TransactionUtils' is defined but never used
import * as IOU from '../libs/actions/IOU';
import * as CurrencyUtils from '../libs/CurrencyUtils';
import FullPageNotFoundView from '../components/BlockingViews/FullPageNotFoundView';
Expand All @@ -29,7 +29,7 @@
field: PropTypes.string,

/** reportID for the "transaction thread" */
threadReportID: PropTypes.string,
reportActionID: PropTypes.string,
}),
}).isRequired,

Expand Down Expand Up @@ -88,12 +88,12 @@
<EditRequestDescriptionPage
defaultDescription={transactionDescription}
onSubmit={(transactionChanges) => {
if (transactionChanges.comment === transactionDescription) {
if (transactionChanges.comment.trim() === transactionDescription) {
Navigation.dismissModal();
return;
}
setDraftSplitTransaction({
comment: transactionChanges.comment,
comment: transactionChanges.comment.trim(),
});
}}
/>
Expand Down
Loading