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
8 changes: 4 additions & 4 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@
};

let conciergeReportIDOnyxConnect: OnyxEntry<string>;
Onyx.connect({

Check warning on line 1039 in src/libs/ReportUtils.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.CONCIERGE_REPORT_ID,
callback: (value) => {
conciergeReportIDOnyxConnect = value;
Expand All @@ -1044,7 +1044,7 @@
});

const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon';
Onyx.connect({

Check warning on line 1047 in src/libs/ReportUtils.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) => {
// When signed out, val is undefined
Expand All @@ -1062,7 +1062,7 @@
let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
let allPersonalDetailLogins: string[];
let currentUserPersonalDetails: OnyxEntry<PersonalDetails>;
Onyx.connect({

Check warning on line 1065 in src/libs/ReportUtils.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) => {
if (currentUserAccountID) {
Expand All @@ -1074,7 +1074,7 @@
});

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

Check warning on line 1077 in src/libs/ReportUtils.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_DRAFT,
waitForCollectionCallback: true,
callback: (value) => (allReportsDraft = value),
Expand All @@ -1082,7 +1082,7 @@

let allPolicies: OnyxCollection<Policy>;
let policiesArray: Policy[] = [];
Onyx.connect({

Check warning on line 1085 in src/libs/ReportUtils.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,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -1092,7 +1092,7 @@
});

let allPolicyDrafts: OnyxCollection<Policy>;
Onyx.connect({

Check warning on line 1095 in src/libs/ReportUtils.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_DRAFTS,
waitForCollectionCallback: true,
callback: (value) => (allPolicyDrafts = value),
Expand All @@ -1100,7 +1100,7 @@

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

Check warning on line 1103 in src/libs/ReportUtils.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 Down Expand Up @@ -1136,14 +1136,14 @@
});

let betaConfiguration: OnyxEntry<BetaConfiguration> = {};
Onyx.connect({

Check warning on line 1139 in src/libs/ReportUtils.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.BETA_CONFIGURATION,
callback: (value) => (betaConfiguration = value ?? {}),
});

let deprecatedAllTransactions: OnyxCollection<Transaction> = {};
let deprecatedReportsTransactions: Record<string, Transaction[]> = {};
Onyx.connect({

Check warning on line 1146 in src/libs/ReportUtils.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 @@ -1169,7 +1169,7 @@
});

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 1172 in src/libs/ReportUtils.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_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand Down Expand Up @@ -4321,19 +4321,19 @@
}

const optionReportMetadata = allReportMetadata?.[`${ONYXKEYS.COLLECTION.REPORT_METADATA}${optionOrReport.reportID}`];
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line @typescript-eslint/no-deprecated
const policy = getPolicy(optionOrReport.policyID);
const invoiceReceiverPolicyID = optionOrReport?.invoiceReceiver && 'policyID' in optionOrReport.invoiceReceiver ? optionOrReport.invoiceReceiver.policyID : undefined;
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line @typescript-eslint/no-deprecated
const invoiceReceiverPolicy = invoiceReceiverPolicyID ? getPolicy(invoiceReceiverPolicyID) : undefined;
const {reportAction: iouReportActionToApproveOrPay, actionBadge} = getIOUReportActionWithBadge(optionOrReport, undefined, optionReportMetadata, invoiceReceiverPolicy);
const {reportAction: iouReportActionToApproveOrPay, actionBadge} = getIOUReportActionWithBadge(optionOrReport, policy, optionReportMetadata, invoiceReceiverPolicy);
const iouReportID = getIOUReportIDFromReportActionPreview(iouReportActionToApproveOrPay);
const transactions = getReportTransactions(iouReportID);
const hasOnlyPendingTransactions = transactions.length > 0 && transactions.every((t) => isExpensifyCardTransaction(t) && isPending(t));

// Has a child report that is awaiting action (e.g. approve, pay, add bank account) from current user
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line @typescript-eslint/no-deprecated
const policy = getPolicy(optionOrReport.policyID);
if (
(optionOrReport.hasOutstandingChildRequest === true || iouReportActionToApproveOrPay?.reportActionID) &&
(policy?.reimbursementChoice !== CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO || !hasOnlyPendingTransactions)
Expand Down
8 changes: 2 additions & 6 deletions src/libs/actions/IOU/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ import {
arePaymentsEnabled,
getDistanceRateCustomUnit,
getMemberAccountIDsForWorkspace,
getPolicy,
getSubmitToAccountID,
hasDependentTags,
hasDynamicExternalWorkflow,
Expand Down Expand Up @@ -9775,7 +9774,7 @@ function canSubmitReport(

function getIOUReportActionWithBadge(
chatReport: OnyxEntry<OnyxTypes.Report>,
updatedIouReport: OnyxEntry<OnyxTypes.Report>,
policy: OnyxEntry<OnyxTypes.Policy>,
reportMetadata: OnyxEntry<OnyxTypes.ReportMetadata>,
invoiceReceiverPolicy: OnyxEntry<OnyxTypes.Policy>,
): {reportAction: OnyxEntry<ReportAction>; actionBadge?: ValueOf<typeof CONST.REPORT.ACTION_BADGE>} {
Expand All @@ -9786,10 +9785,7 @@ function getIOUReportActionWithBadge(
if (!action || action.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW || isDeletedAction(action)) {
return false;
}
const iouReport = updatedIouReport?.reportID === action.childReportID ? updatedIouReport : getReportOrDraftReport(action.childReportID);
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line @typescript-eslint/no-deprecated
const policy = getPolicy(iouReport?.policyID);
const iouReport = getReportOrDraftReport(action.childReportID);
// Only show to the actual payer, exclude admins with bank account access
if (canIOUBePaid(iouReport, chatReport, policy, undefined, undefined, undefined, undefined, invoiceReceiverPolicy)) {
actionBadge = CONST.REPORT.ACTION_BADGE.PAY;
Expand Down
10 changes: 5 additions & 5 deletions tests/actions/IOUTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13389,7 +13389,7 @@ describe('actions/IOU', () => {

await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${fakeReport.reportID}`, MOCK_REPORT_ACTIONS);

const result = getIOUReportActionWithBadge(fakeReport, undefined, {}, undefined);
const result = getIOUReportActionWithBadge(fakeReport, fakePolicy, {}, undefined);
expect(result.reportAction).toMatchObject(MOCK_REPORT_ACTIONS[reportID]);
expect(result.actionBadge).toBe(CONST.REPORT.ACTION_BADGE.APPROVE);
});
Expand Down Expand Up @@ -13447,7 +13447,7 @@ describe('actions/IOU', () => {
});
await waitForBatchedUpdates();

const result = getIOUReportActionWithBadge(fakeChatReport, undefined, {}, undefined);
const result = getIOUReportActionWithBadge(fakeChatReport, fakePolicy, {}, undefined);
expect(result.reportAction).toMatchObject(reportPreviewAction);
expect(result.actionBadge).toBe(CONST.REPORT.ACTION_BADGE.APPROVE);
});
Expand Down Expand Up @@ -13510,7 +13510,7 @@ describe('actions/IOU', () => {
});
await waitForBatchedUpdates();

const result = getIOUReportActionWithBadge(fakeChatReport, undefined, {}, undefined);
const result = getIOUReportActionWithBadge(fakeChatReport, fakePolicy, {}, undefined);
expect(result.reportAction).toMatchObject(reportPreviewAction);
expect(result.actionBadge).toBe(CONST.REPORT.ACTION_BADGE.PAY);
});
Expand Down Expand Up @@ -13574,7 +13574,7 @@ describe('actions/IOU', () => {
});
await waitForBatchedUpdates();

const result = getIOUReportActionWithBadge(fakeChatReport, undefined, {}, undefined);
const result = getIOUReportActionWithBadge(fakeChatReport, fakePolicy, {}, undefined);
expect(result.reportAction).toMatchObject(reportPreviewAction);
expect(result.actionBadge).toBe(CONST.REPORT.ACTION_BADGE.SUBMIT);
});
Expand Down Expand Up @@ -13633,7 +13633,7 @@ describe('actions/IOU', () => {
});
await waitForBatchedUpdates();

const result = getIOUReportActionWithBadge(fakeChatReport, undefined, {}, undefined);
const result = getIOUReportActionWithBadge(fakeChatReport, fakePolicy, {}, undefined);
expect(result.reportAction).toBeUndefined();
expect(result.actionBadge).toBeUndefined();
});
Expand Down
Loading