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
2 changes: 1 addition & 1 deletion src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ function MoneyReportHeader({

duplicateExpenseTransaction([transaction]);
},
shouldCloseModalOnSelect: false,
shouldCloseModalOnSelect: activePolicyExpenseChat?.iouReportID === moneyRequestReport?.reportID,
},
[CONST.REPORT.SECONDARY_ACTIONS.CHANGE_WORKSPACE]: {
text: translate('iou.changeWorkspace'),
Expand Down
22 changes: 11 additions & 11 deletions src/components/PopoverMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,19 +309,19 @@ function BasePopoverMenu({
setEnteredSubMenuIndexes([...enteredSubMenuIndexes, index]);
const selectedSubMenuItemIndex = selectedItem?.subMenuItems.findIndex((option) => option.isSelected);
setFocusedIndex(selectedSubMenuItemIndex);
} else if (selectedItem.shouldCloseModalOnSelect === false) {
onItemSelected?.(selectedItem, index, event);
selectedItem.onSelected?.();
setFocusedIndex(-1);
} else if (selectedItem.shouldCallAfterModalHide && (!isSafari() || shouldAvoidSafariException)) {
onItemSelected?.(selectedItem, index, event);
if (selectedItem.shouldCloseModalOnSelect !== false) {
close(
() => {
selectedItem.onSelected?.();
},
undefined,
selectedItem.shouldCloseAllModals,
);
} else {
selectedItem.onSelected?.();
}
close(
() => {
selectedItem.onSelected?.();
},
undefined,
selectedItem.shouldCloseAllModals,
);
} else {
onItemSelected?.(selectedItem, index, event);
selectedItem.onSelected?.();
Expand Down
6 changes: 2 additions & 4 deletions src/libs/ReportSecondaryActionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -767,8 +767,7 @@ function getSecondaryReportActions({
options.push(CONST.REPORT.SECONDARY_ACTIONS.MERGE);
}

// Disabled for now to fix deploy blockers. Will be re-enabled in https://github.com/Expensify/App/pull/77343
if (isDuplicateAction(report, reportTransactions) && false) {
if (isDuplicateAction(report, reportTransactions)) {
options.push(CONST.REPORT.SECONDARY_ACTIONS.DUPLICATE);
}

Expand Down Expand Up @@ -848,8 +847,7 @@ function getSecondaryTransactionThreadActions(
options.push(CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.MERGE);
}

// Disabled for now to fix deploy blockers. Will be re-enabled in https://github.com/Expensify/App/pull/77343
if (isDuplicateAction(parentReport, [reportTransaction]) && false) {
if (isDuplicateAction(parentReport, [reportTransaction])) {
options.push(CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.DUPLICATE);
}

Expand Down
12 changes: 3 additions & 9 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@
};

let allPersonalDetails: OnyxTypes.PersonalDetailsList = {};
Onyx.connect({

Check warning on line 745 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
allPersonalDetails = value ?? {};
Expand Down Expand Up @@ -838,7 +838,7 @@
};

let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 841 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -852,7 +852,7 @@
});

let allTransactionDrafts: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 855 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_DRAFT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -861,7 +861,7 @@
});

let allTransactionViolations: NonNullable<OnyxCollection<OnyxTypes.TransactionViolations>> = {};
Onyx.connect({

Check warning on line 864 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -875,7 +875,7 @@
});

let allNextSteps: NonNullable<OnyxCollection<OnyxTypes.ReportNextStepDeprecated>> = {};
Onyx.connect({

Check warning on line 878 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.NEXT_STEP,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -887,14 +887,14 @@
// `allRecentlyUsedTags` was moved here temporarily from `src/libs/actions/Policy/Tag.ts` during the `Deprecate Onyx.connect` refactor.
// All uses of this variable should be replaced with `useOnyx`.
let allRecentlyUsedTags: OnyxCollection<RecentlyUsedTags> = {};
Onyx.connect({

Check warning on line 890 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS,
waitForCollectionCallback: true,
callback: (val) => (allRecentlyUsedTags = val),
});

let allReports: OnyxCollection<OnyxTypes.Report>;
Onyx.connect({

Check warning on line 897 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -903,7 +903,7 @@
});

let allReportNameValuePairs: OnyxCollection<OnyxTypes.ReportNameValuePairs>;
Onyx.connect({

Check warning on line 906 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -913,7 +913,7 @@

let userAccountID = -1;
let currentUserEmail = '';
Onyx.connect({

Check warning on line 916 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
currentUserEmail = value?.email ?? '';
Expand All @@ -922,7 +922,7 @@
});

let deprecatedCurrentUserPersonalDetails: OnyxEntry<OnyxTypes.PersonalDetails>;
Onyx.connect({

Check warning on line 925 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
deprecatedCurrentUserPersonalDetails = value?.[userAccountID] ?? undefined;
Expand Down Expand Up @@ -6924,13 +6924,13 @@
...transaction,
...transactionDetails,
attendees: transactionDetails?.attendees as Attendee[] | undefined,
comment: transactionDetails?.comment,
comment: Parser.htmlToMarkdown(transactionDetails?.comment ?? ''),
created: format(new Date(), CONST.DATE.FNS_FORMAT_STRING),
customUnitRateID: transaction?.comment?.customUnit?.customUnitRateID,
isTestDrive: transaction?.receipt?.isTestDriveReceipt,
merchant: transaction?.modifiedMerchant ? transaction.modifiedMerchant : (transaction?.merchant ?? ''),
modifiedAmount: undefined,
originalTransactionID: transaction?.comment?.originalTransactionID,
originalTransactionID: undefined,
Comment thread
jjcoffee marked this conversation as resolved.
receipt: undefined,
source: undefined,
waypoints: transactionDetails?.waypoints as WaypointCollection | undefined,
Expand All @@ -6945,12 +6945,6 @@

// If no workspace is provided the expense should be unreported
if (!targetPolicy) {
const selfDMReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${findSelfDMReportID()}`];

if (!selfDMReport) {
return;
}

const trackExpenseParams: CreateTrackExpenseParams = {
...params,
participantParams: {
Expand All @@ -6961,7 +6955,7 @@
...(params.transactionParams ?? {}),
validWaypoints: transactionDetails?.waypoints as WaypointCollection | undefined,
},
report: selfDMReport,
report: undefined,
isDraftPolicy: false,
};
return trackExpense(trackExpenseParams);
Expand Down
87 changes: 43 additions & 44 deletions tests/unit/ReportSecondaryActionUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1721,50 +1721,49 @@ describe('getSecondaryAction', () => {
expect(result).not.toContain(CONST.REPORT.SECONDARY_ACTIONS.REMOVE_HOLD);
});

// Will be re-enabled in https://github.com/Expensify/App/pull/77343
// it('include DUPLICATE option for single-transaction expense report', () => {
// const report = {
// reportID: REPORT_ID,
// type: CONST.REPORT.TYPE.EXPENSE,
// ownerAccountID: EMPLOYEE_ACCOUNT_ID,
// statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED,
// stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
// } as unknown as Report;

// const TRANSACTION_ID = 'TRANSACTION_ID';

// const transaction1 = {
// transactionID: TRANSACTION_ID,
// reportID: REPORT_ID,
// } as unknown as Transaction;

// const reportActions = [
// {
// reportActionID: '1',
// actorAccountID: EMPLOYEE_ACCOUNT_ID,
// actionName: CONST.REPORT.ACTIONS.TYPE.IOU,
// originalMessage: {
// IOUTransactionID: TRANSACTION_ID,
// IOUReportID: REPORT_ID,
// },
// },
// ] as unknown as ReportAction[];

// const policy = {} as unknown as Policy;

// const result = getSecondaryReportActions({
// currentUserEmail: EMPLOYEE_EMAIL,
// currentUserAccountID: EMPLOYEE_ACCOUNT_ID,
// report,
// chatReport,
// reportTransactions: [transaction1],
// originalTransaction: {} as Transaction,
// violations: {},
// policy,
// reportActions,
// });
// expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DUPLICATE)).toBe(true);
// });
it('include DUPLICATE option for single-transaction expense report', () => {
const report = {
reportID: REPORT_ID,
type: CONST.REPORT.TYPE.EXPENSE,
ownerAccountID: EMPLOYEE_ACCOUNT_ID,
statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED,
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
} as unknown as Report;

const TRANSACTION_ID = 'TRANSACTION_ID';

const transaction1 = {
transactionID: TRANSACTION_ID,
reportID: REPORT_ID,
} as unknown as Transaction;

const reportActions = [
{
reportActionID: '1',
actorAccountID: EMPLOYEE_ACCOUNT_ID,
actionName: CONST.REPORT.ACTIONS.TYPE.IOU,
originalMessage: {
IOUTransactionID: TRANSACTION_ID,
IOUReportID: REPORT_ID,
},
},
] as unknown as ReportAction[];

const policy = {} as unknown as Policy;

const result = getSecondaryReportActions({
currentUserEmail: EMPLOYEE_EMAIL,
currentUserAccountID: EMPLOYEE_ACCOUNT_ID,
report,
chatReport,
reportTransactions: [transaction1],
originalTransaction: {} as Transaction,
violations: {},
policy,
reportActions,
});
expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.DUPLICATE)).toBe(true);
});

it('does not include DUPLICATE option if there are no transactions', async () => {
const report = {
Expand Down
Loading