Skip to content

Commit f3a98f2

Browse files
authored
Merge pull request Expensify#75507 from etCoderDysto/fix_74022
fix: Reports - "Waiting for you to fix the issue" briefly seen when moving expense to new report
2 parents 26dfc14 + 49a4cbd commit f3a98f2

2 files changed

Lines changed: 40 additions & 3 deletions

File tree

src/pages/Search/SearchTransactionsChangeReport.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function SearchTransactionsChangeReport() {
103103
optimisticReport,
104104
policyForMovingExpensesID ? allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyForMovingExpensesID}`] : undefined,
105105
reportNextStep,
106-
undefined,
106+
allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyForMovingExpensesID}`],
107107
);
108108
clearSelectedTransactions();
109109
});

tests/unit/TransactionTest.ts

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ import ONYXKEYS from '@src/ONYXKEYS';
1313
import type {Attendee} from '@src/types/onyx/IOU';
1414
import type {ReportCollectionDataSet} from '@src/types/onyx/Report';
1515
import * as TransactionUtils from '../../src/libs/TransactionUtils';
16-
import type {RecentWaypoint, Report, ReportAction, ReportActions, Transaction} from '../../src/types/onyx';
17-
import {createRandomReport} from '../utils/collections/reports';
16+
import type {PersonalDetails, RecentWaypoint, Report, ReportAction, ReportActions, Transaction} from '../../src/types/onyx';
17+
import createRandomPolicy from '../utils/collections/policies';
18+
import createRandomPolicyCategories from '../utils/collections/policyCategory';
19+
import {createExpenseReport, createRandomReport} from '../utils/collections/reports';
20+
import getOnyxValue from '../utils/getOnyxValue';
1821
import waitForBatchedUpdates from '../utils/waitForBatchedUpdates';
1922

2023
function generateTransaction(values: Partial<Transaction> = {}): Transaction {
@@ -575,6 +578,40 @@ describe('Transaction', () => {
575578
expect(report?.total).toBe(oldExpenseReport.total);
576579
expect(report?.nonReimbursableTotal).toBe(oldExpenseReport.nonReimbursableTotal);
577580
});
581+
582+
it('should show "waiting for you to submit expense" next step message when moving expense to a new report ', async () => {
583+
const policyID = '12346';
584+
const oldExpenseReportID = '5';
585+
586+
const transaction = generateTransaction({reportID: oldExpenseReportID});
587+
588+
const newOpenReport = {...createExpenseReport(6334), policyID, stateNum: CONST.REPORT.STATE_NUM.OPEN, statusNum: CONST.REPORT.STATUS_NUM.OPEN, ownerAccountID: CURRENT_USER_ID};
589+
590+
const policy = {...createRandomPolicy(Number(policyID)), harvesting: {enabled: false}, autoReportingFrequency: CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE};
591+
592+
const policyCategories = createRandomPolicyCategories(5);
593+
594+
const userPersonalDetails: Record<number, PersonalDetails> = {
595+
[CURRENT_USER_ID]: {
596+
login: 'test@gmail.com',
597+
accountID: CURRENT_USER_ID,
598+
displayName: 'You',
599+
},
600+
};
601+
602+
await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`, transaction);
603+
await Onyx.merge(`${ONYXKEYS.PERSONAL_DETAILS_LIST}`, userPersonalDetails);
604+
605+
changeTransactionsReport([transaction.transactionID], false, CURRENT_USER_ID, 'test@gmail.com', newOpenReport, policy, undefined, policyCategories);
606+
607+
await waitForBatchedUpdates();
608+
609+
const nextStep = await getOnyxValue(`${ONYXKEYS.COLLECTION.NEXT_STEP}${newOpenReport.reportID}`);
610+
611+
const nextStepMessage = nextStep?.message?.map((part) => part.text).join('');
612+
613+
expect(nextStepMessage).toEqual('Waiting for You to submit %expenses.');
614+
});
578615
});
579616

580617
describe('getAllNonDeletedTransactions', () => {

0 commit comments

Comments
 (0)