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

Fix - Distance - After tapping split expense with amount button, briefly "split expense" button shown #52428

Merged
Merged
Changes from 1 commit
Commits
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
32 changes: 9 additions & 23 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {format} from 'date-fns';
import {fastMerge, Str} from 'expensify-common';
import {InteractionManager} from 'react-native';
import type {NullishDeep, OnyxCollection, OnyxEntry, OnyxInputValue, OnyxUpdate} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import type {PartialDeep, SetRequired, ValueOf} from 'type-fest';
Expand Down Expand Up @@ -74,6 +75,7 @@ import * as Policy from './Policy/Policy';
import * as Tag from './Policy/Tag';
import * as Report from './Report';
import {getRecentWaypoints, sanitizeRecentWaypoints} from './Transaction';
import * as TransactionEdit from './TransactionEdit';

type IOURequestType = ValueOf<typeof CONST.IOU.REQUEST_TYPE>;

Expand Down Expand Up @@ -624,12 +626,6 @@ function buildOnyxDataForMoneyRequest(
pendingFields: {createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD},
},
},
// Remove the temporary transaction used during the creation flow
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`,
value: null,
},
);

if (!isEmptyObject(transactionThreadCreatedReportAction)) {
Expand Down Expand Up @@ -1004,12 +1000,6 @@ function buildOnyxDataForInvoice(
[transactionThreadCreatedReportAction?.reportActionID ?? '-1']: transactionThreadCreatedReportAction,
},
},
// Remove the temporary transaction used during the creation flow
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`,
value: null,
},
];
const successData: OnyxUpdate[] = [];

Expand Down Expand Up @@ -1451,12 +1441,6 @@ function buildOnyxDataForTrackExpense(
pendingFields: {createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD},
},
},
// Remove the temporary transaction used during the creation flow
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`,
value: null,
},
);

if (!isEmptyObject(transactionThreadCreatedReportAction)) {
Expand Down Expand Up @@ -3680,6 +3664,7 @@ function requestMoney(
}
}

InteractionManager.runAfterInteractions(() => TransactionEdit.removeDraftTransaction(CONST.IOU.OPTIMISTIC_TRANSACTION_ID));
FitseTLT marked this conversation as resolved.
Show resolved Hide resolved
Navigation.dismissModal(isSearchTopmostCentralPane() ? undefined : activeReportID);
if (activeReportID) {
Report.notifyNewAction(activeReportID, payeeAccountID);
Expand Down Expand Up @@ -3736,6 +3721,7 @@ function sendInvoice(
};

API.write(WRITE_COMMANDS.SEND_INVOICE, parameters, onyxData);
InteractionManager.runAfterInteractions(() => TransactionEdit.removeDraftTransaction(CONST.IOU.OPTIMISTIC_TRANSACTION_ID));

if (isSearchTopmostCentralPane()) {
Navigation.dismissModal();
Expand Down Expand Up @@ -3931,6 +3917,7 @@ function trackExpense(
API.write(WRITE_COMMANDS.TRACK_EXPENSE, parameters, onyxData);
}
}
InteractionManager.runAfterInteractions(() => TransactionEdit.removeDraftTransaction(CONST.IOU.OPTIMISTIC_TRANSACTION_ID));
Navigation.dismissModal(isSearchTopmostCentralPane() ? undefined : activeReportID);

if (action === CONST.IOU.ACTION.SHARE) {
Expand Down Expand Up @@ -4118,11 +4105,6 @@ function createSplitsAndOnyxData(
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${splitTransaction.transactionID}`,
value: splitTransaction,
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`,
value: null,
},
];
const successData: OnyxUpdate[] = [
{
Expand Down Expand Up @@ -4501,6 +4483,7 @@ function splitBill({
};

API.write(WRITE_COMMANDS.SPLIT_BILL, parameters, onyxData);
InteractionManager.runAfterInteractions(() => TransactionEdit.removeDraftTransaction(CONST.IOU.OPTIMISTIC_TRANSACTION_ID));

Navigation.dismissModal(isSearchTopmostCentralPane() ? undefined : existingSplitChatReportID);
Report.notifyNewAction(splitData.chatReportID, currentUserAccountID);
Expand Down Expand Up @@ -4568,6 +4551,7 @@ function splitBillAndOpenReport({
};

API.write(WRITE_COMMANDS.SPLIT_BILL_AND_OPEN_REPORT, parameters, onyxData);
InteractionManager.runAfterInteractions(() => TransactionEdit.removeDraftTransaction(CONST.IOU.OPTIMISTIC_TRANSACTION_ID));

Navigation.dismissModal(isSearchTopmostCentralPane() ? undefined : splitData.chatReportID);
Report.notifyNewAction(splitData.chatReportID, currentUserAccountID);
Expand Down Expand Up @@ -5138,6 +5122,7 @@ function completeSplitBill(chatReportID: string, reportAction: OnyxTypes.ReportA
};

API.write(WRITE_COMMANDS.COMPLETE_SPLIT_BILL, parameters, {optimisticData, successData, failureData});
InteractionManager.runAfterInteractions(() => TransactionEdit.removeDraftTransaction(CONST.IOU.OPTIMISTIC_TRANSACTION_ID));
Navigation.dismissModal(isSearchTopmostCentralPane() ? undefined : chatReportID);
Report.notifyNewAction(chatReportID, sessionAccountID);
}
Expand Down Expand Up @@ -5315,6 +5300,7 @@ function createDistanceRequest(
});

API.write(WRITE_COMMANDS.CREATE_DISTANCE_REQUEST, parameters, onyxData);
InteractionManager.runAfterInteractions(() => TransactionEdit.removeDraftTransaction(CONST.IOU.OPTIMISTIC_TRANSACTION_ID));
const activeReportID = isMoneyRequestReport ? report?.reportID ?? '-1' : parameters.chatReportID;
Navigation.dismissModal(isSearchTopmostCentralPane() ? undefined : activeReportID);
Report.notifyNewAction(activeReportID, userAccountID);
Expand Down
Loading