-
Notifications
You must be signed in to change notification settings - Fork 4k
Scan - Split details page does not show the new UI when scan expense is split offline #102799
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1256,6 +1256,85 @@ describe('split expense', () => { | |
| expect(splitTransaction?.comment?.comment).toBe('<h1>test</h1>'); | ||
| }); | ||
|
|
||
| it('should stop treating the split as a scan request once it is completed while offline', async () => { | ||
| // Given a scan split bill started offline, so it is marked as a scan request | ||
| const reportID = '1'; | ||
| await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, { | ||
| reportID, | ||
| type: CONST.REPORT.TYPE.CHAT, | ||
| chatType: CONST.REPORT.CHAT_TYPE.GROUP, | ||
| participants: { | ||
| [RORY_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS}, | ||
| [CARLOS_ACCOUNT_ID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS}, | ||
| }, | ||
| }); | ||
|
|
||
| const participants: IOUParticipant[] = [{accountID: CARLOS_ACCOUNT_ID, login: CARLOS_EMAIL}]; | ||
| const participantsPolicyTags = await getParticipantsPolicyTags(participants); | ||
|
|
||
| mockFetch?.pause?.(); | ||
|
|
||
| startSplitBill({ | ||
| isFirstSplitInBatch: true, | ||
| getCurrencyDecimals: getCurrencyDecimalsLocal, | ||
| participants, | ||
| currentUserLogin: RORY_EMAIL, | ||
| currentUserAccountID: RORY_ACCOUNT_ID, | ||
| comment: '', | ||
| currency: CONST.CURRENCY.USD, | ||
| existingSplitChatReportID: reportID, | ||
| receipt: {source: 'file://receipt.jpg', filename: 'receipt.jpg', state: CONST.IOU.RECEIPT_STATE.SCAN_READY}, | ||
| category: undefined, | ||
| tag: undefined, | ||
| taxCode: '', | ||
| taxAmount: 0, | ||
| quickAction: undefined, | ||
| policyRecentlyUsedCurrencies: [], | ||
| policyRecentlyUsedTags: undefined, | ||
| participantsPolicyTags, | ||
| delegateAccountID: undefined, | ||
| formatPhoneNumber, | ||
| }); | ||
|
|
||
| await waitForBatchedUpdates(); | ||
|
|
||
| let splitTransaction = await getScanSplitTransaction(); | ||
| const splitTransactionID = splitTransaction?.transactionID; | ||
| expect(splitTransaction?.iouRequestType).toBe(CONST.IOU.REQUEST_TYPE.SCAN); | ||
|
|
||
| const reportActions = await getOnyxValue(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`); | ||
| const iouAction = Object.values(reportActions ?? {}).find((action) => isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.IOU)); | ||
|
|
||
| // When the user fills the fields in by hand and completes the split while still offline | ||
| completeSplitBill({ | ||
| isVendorMatchingBetaEnabled: false, | ||
| getCurrencyDecimals: getCurrencyDecimalsLocal, | ||
| chatReportID: reportID, | ||
| reportAction: iouAction, | ||
| updatedTransaction: splitTransaction ? {...splitTransaction, amount: 100, modifiedAmount: 100, modifiedCurrency: CONST.CURRENCY.USD} : undefined, | ||
| sessionAccountID: RORY_ACCOUNT_ID, | ||
| isASAPSubmitBetaEnabled: false, | ||
| quickAction: undefined, | ||
| transactionViolations: {}, | ||
| personalDetails: mockPersonalDetails, | ||
| delegateAccountID: undefined, | ||
| isTrackIntentUser: false, | ||
| sessionEmail: RORY_EMAIL, | ||
| formatPhoneNumber, | ||
| rules: undefined, | ||
| }); | ||
|
|
||
| await waitForBatchedUpdates(); | ||
|
|
||
| // Then the optimistic transaction is no longer a scan request, so the split details page renders the | ||
| // manual layout right away instead of waiting for the server response to arrive | ||
| splitTransaction = await getOnyxValue(`${ONYXKEYS.COLLECTION.TRANSACTION}${splitTransactionID}`); | ||
| expect(splitTransaction?.iouRequestType).toBe(CONST.IOU.REQUEST_TYPE.MANUAL); | ||
|
|
||
| mockFetch?.resume?.(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🟢 The fix depends on Can we fail the request here and check that it rolls back ? Then a future change to mockFetch?.fail?.();
await mockFetch?.resume?.();
await waitForBatchedUpdates();
// Then the split goes back to being a scan request so the user can retry from the original state
splitTransaction = await getOnyxValue(`${ONYXKEYS.COLLECTION.TRANSACTION}${splitTransactionID}`);
expect(splitTransaction?.iouRequestType).toBe(CONST.IOU.REQUEST_TYPE.SCAN);
expect(splitTransaction?.errors).toBeTruthy();(This also awaits |
||
| await waitForBatchedUpdates(); | ||
| }); | ||
|
|
||
| it('should calculate proportional convertedAmount for split transactions with foreign currency', async () => { | ||
| jest.setTimeout(10 * 1000); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/libs/actions/IOU/Split.ts:951🟢 Could we add a short comment here explaining why ? It's not obvious from the code alone why completing a split flips the type. Without context, someone could later "clean up" this line and quietly bring back #102491.
Something like: