Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions src/libs/API/parameters/CreateAppReportParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type CreateAppReportParams = {
reportActionID: string;
reportPreviewReportActionID: string;
ownerEmail?: string;
managedCardTransactionID?: string;
shouldDismissEmptyReportsConfirmation?: boolean;
reportName?: string;
};
Expand Down
14 changes: 3 additions & 11 deletions src/libs/actions/IOU/Duplicate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -950,17 +950,9 @@ function duplicateReport({
}

const newReportName = translate('common.copyOfReportName', sourceReportName);
const {reportPreviewReportActionID, ...newReport} = createNewReport(
ownerPersonalDetails,
false,
isASAPSubmitBetaEnabled,
targetPolicy,
betas,
isTrackIntentUser,
false,
undefined,
newReportName,
);
const {reportPreviewReportActionID, ...newReport} = createNewReport(ownerPersonalDetails, false, isASAPSubmitBetaEnabled, targetPolicy, betas, isTrackIntentUser, false, undefined, {
reportName: newReportName,
});

const isCrossWorkspace = !!sourceReport && sourceReport.policyID !== targetPolicy.id;

Expand Down
4 changes: 3 additions & 1 deletion src/libs/actions/Report/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4308,8 +4308,9 @@ function createNewReport(
isTrackIntentUser: boolean | undefined,
shouldNotifyNewAction = false,
shouldDismissEmptyReportsConfirmation?: boolean,
reportName?: string,
options: {managedCardTransactionID?: string; reportName?: string} = {},
) {
const {managedCardTransactionID, reportName} = options;
const optimisticReportID = generateReportID();
const reportActionID = rand64();
const reportPreviewReportActionID = rand64();
Expand Down Expand Up @@ -4340,6 +4341,7 @@ function createNewReport(
reportActionID,
reportPreviewReportActionID,
ownerEmail: ownerPersonalDetails.login,
...(managedCardTransactionID ? {managedCardTransactionID} : {}),
...(shouldDismissEmptyReportsConfirmation ? {shouldDismissEmptyReportsConfirmation} : {}),
...(reportName ? {reportName} : {}),
},
Expand Down
4 changes: 3 additions & 1 deletion src/pages/Search/SearchTransactionsChangeReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ function SearchTransactionsChangeReport() {
const [selfDMReportID] = useOnyx(ONYXKEYS.SELF_DM_REPORT_ID);
const [selfDMReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${getNonEmptyStringOnyxID(selfDMReportID)}`);
const hasPerDiemTransactions = useHasPerDiemTransactions(selectedTransactionsKeys);
const hasUnreportedManagedCardTransactions = transactions.some((transaction) => isUnreportedManagedCardTransaction(transaction));
const managedCardTransactionID = transactions.find((transaction) => isUnreportedManagedCardTransaction(transaction))?.transactionID;
const hasUnreportedManagedCardTransactions = !!managedCardTransactionID;
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
const [isTrackIntentUser] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {selector: isTrackIntentUserSelector});
const {isBetaEnabled} = usePermissions();
Expand Down Expand Up @@ -157,6 +158,7 @@ function SearchTransactionsChangeReport() {
isTrackIntentUser,
false,
shouldDismissEmptyReportsConfirmation,
{managedCardTransactionID},
);
const reportNextStep = allReportNextSteps?.[`${ONYXKEYS.COLLECTION.NEXT_STEP}${optimisticReport.reportID}`];
const policyTagList = policyForMovingExpenses?.id ? allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyForMovingExpenses.id}`] : {};
Expand Down
4 changes: 3 additions & 1 deletion src/pages/iou/request/step/IOURequestEditReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ function IOURequestEditReport({route}: IOURequestEditReportProps) {
[personalDetails, selectedReport?.ownerAccountID],
);
const [transactions] = useTransactionsByID(transactionIDs);
const hasUnreportedManagedCardTransactions = transactions.some((transaction) => isUnreportedManagedCardTransaction(transaction));
const managedCardTransactionID = transactions.find((transaction) => isUnreportedManagedCardTransaction(transaction))?.transactionID;
const hasUnreportedManagedCardTransactions = !!managedCardTransactionID;
const hasPerDiemTransactions = useHasPerDiemTransactions(transactionIDs);

// When moving an expense that belongs to another user, or when the selection includes per diem
Expand Down Expand Up @@ -163,6 +164,7 @@ function IOURequestEditReport({route}: IOURequestEditReportProps) {
isTrackIntentUser,
false,
shouldDismissEmptyReportsConfirmation,
{managedCardTransactionID},
);
selectReport(
{
Expand Down
1 change: 1 addition & 0 deletions src/pages/iou/request/step/IOURequestStepReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) {
isTrackIntentUser,
false,
shouldDismissEmptyReportsConfirmation,
{managedCardTransactionID: isUnreportedManagedCardTransaction ? transactionID : undefined},
);
handleRegularReportSelection({value: optimisticReport.reportID, keyForList: optimisticReport.reportID, policyID: policyForNewReport?.id}, optimisticReport);
};
Expand Down
12 changes: 12 additions & 0 deletions tests/actions/ReportTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2733,6 +2733,18 @@ describe('actions/Report', () => {
});
});

it('should pass managed card transaction context when creating a new report', () => {
const managedCardTransactionID = '123456789';
const policy = {
...createRandomPolicy(5678),
type: CONST.POLICY.TYPE.TEAM,
};

Report.createNewReport({accountID: 1234}, true, false, policy, [CONST.BETAS.ALL], false, false, undefined, {managedCardTransactionID});

expect(apiWriteSpy).toHaveBeenCalledWith(WRITE_COMMANDS.CREATE_APP_REPORT, expect.objectContaining({managedCardTransactionID}), expect.anything());
});

it('should set hasOnceLoadedReportActions for parent report metadata when creating a new report', async () => {
const accountID = 1234;
const policyID = '5678';
Expand Down
Loading