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 - Track expense - App is stuck on confirmation page when submitting track expense #54410

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
7 changes: 4 additions & 3 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1882,11 +1882,12 @@ function buildOnyxDataForTrackExpense(
const successData: OnyxUpdate[] = [];
const failureData: OnyxUpdate[] = [];

let newQuickAction: ValueOf<typeof CONST.QUICK_ACTIONS> = CONST.QUICK_ACTIONS.TRACK_MANUAL;
const isSelfDMReport = isSelfDM(chatReport);
let newQuickAction: ValueOf<typeof CONST.QUICK_ACTIONS> = isSelfDMReport ? CONST.QUICK_ACTIONS.TRACK_MANUAL : CONST.QUICK_ACTIONS.REQUEST_MANUAL;
if (isScanRequest) {
newQuickAction = CONST.QUICK_ACTIONS.TRACK_SCAN;
newQuickAction = isSelfDMReport ? CONST.QUICK_ACTIONS.TRACK_SCAN : CONST.QUICK_ACTIONS.REQUEST_SCAN;
} else if (isDistanceRequest) {
newQuickAction = CONST.QUICK_ACTIONS.TRACK_DISTANCE;
newQuickAction = isSelfDMReport ? CONST.QUICK_ACTIONS.TRACK_DISTANCE : CONST.QUICK_ACTIONS.REQUEST_DISTANCE;
}
const existingTransactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${existingTransactionThreadReportID}`] ?? null;

Expand Down
19 changes: 17 additions & 2 deletions tests/actions/IOUTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe('actions/IOU', () => {
};

// Given a policyExpenseChat report
const expenseReport = {
const policyExpenseChat = {
...createRandomReport(1),
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
};
Expand Down Expand Up @@ -279,7 +279,7 @@ describe('actions/IOU', () => {

// When the user confirms the category for the tracked expense
trackExpense({
report: expenseReport,
report: policyExpenseChat,
isDraftPolicy: false,
action: CONST.IOU.ACTION.CATEGORIZE,
participantParams: {
Expand Down Expand Up @@ -326,6 +326,21 @@ describe('actions/IOU', () => {
},
});
});

await new Promise<void>((resolve) => {
const connection = Onyx.connect({
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
callback: (quickAction) => {
Onyx.disconnect(connection);
resolve();

// Then the quickAction.action should be set to REQUEST_DISTANCE
expect(quickAction?.action).toBe(CONST.QUICK_ACTIONS.REQUEST_DISTANCE);
// Then the quickAction.chatReportID should be set to the given policyExpenseChat reportID
expect(quickAction?.chatReportID).toBe(policyExpenseChat.reportID);
},
});
});
});
});

Expand Down
Loading