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
13 changes: 10 additions & 3 deletions src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,22 @@ const taskColumnNamesToSortingProperty = {
};

const expenseStatusActionMapping = {
// eslint-disable-next-line @typescript-eslint/no-deprecated
[CONST.SEARCH.STATUS.EXPENSE.DRAFTS]: (expenseReport: SearchReport) =>
expenseReport?.stateNum === CONST.REPORT.STATE_NUM.OPEN && expenseReport.statusNum === CONST.REPORT.STATUS_NUM.OPEN,
// eslint-disable-next-line @typescript-eslint/no-deprecated
[CONST.SEARCH.STATUS.EXPENSE.OUTSTANDING]: (expenseReport: SearchReport) =>
expenseReport?.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED && expenseReport.statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED,
// eslint-disable-next-line @typescript-eslint/no-deprecated
[CONST.SEARCH.STATUS.EXPENSE.APPROVED]: (expenseReport: SearchReport) =>
expenseReport?.stateNum === CONST.REPORT.STATE_NUM.APPROVED && expenseReport.statusNum === CONST.REPORT.STATUS_NUM.APPROVED,
// eslint-disable-next-line @typescript-eslint/no-deprecated
[CONST.SEARCH.STATUS.EXPENSE.PAID]: (expenseReport: SearchReport) =>
(expenseReport?.stateNum ?? 0) >= CONST.REPORT.STATE_NUM.APPROVED && expenseReport.statusNum === CONST.REPORT.STATUS_NUM.REIMBURSED,
// eslint-disable-next-line @typescript-eslint/no-deprecated
[CONST.SEARCH.STATUS.EXPENSE.DONE]: (expenseReport: SearchReport) =>
expenseReport?.stateNum === CONST.REPORT.STATE_NUM.APPROVED && expenseReport.statusNum === CONST.REPORT.STATUS_NUM.CLOSED,
// eslint-disable-next-line @typescript-eslint/no-deprecated
[CONST.SEARCH.STATUS.EXPENSE.UNREPORTED]: (expenseReport: SearchReport) => !expenseReport,
[CONST.SEARCH.STATUS.EXPENSE.ALL]: () => true,
};
Expand Down Expand Up @@ -883,6 +889,7 @@ function getViolations(data: OnyxTypes.SearchResults['data']): OnyxCollection<On
* @private
* Generates a display name for IOU reports considering the personal details of the payer and the transaction details.
*/
// eslint-disable-next-line @typescript-eslint/no-deprecated
function getIOUReportName(data: OnyxTypes.SearchResults['data'], reportItem: SearchReport) {
const payerPersonalDetails = reportItem.managerID ? data.personalDetailsList?.[reportItem.managerID] : emptyPersonalDetails;
// For cases where the data personal detail for manager ID do not exist in search data.personalDetailsList
Expand Down Expand Up @@ -1447,7 +1454,7 @@ function getReportSections(
allActions,
keyForList: String(reportItem.reportID),
groupedBy: CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT,
from: transactions.length > 0 ? data.personalDetailsList[data?.[reportKey as ReportKey]?.accountID ?? CONST.DEFAULT_NUMBER_ID] : emptyPersonalDetails,
from: transactions.length > 0 ? data.personalDetailsList[data?.[reportKey as ReportKey]?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID] : emptyPersonalDetails,
to: !shouldShowBlankTo && reportItem.managerID ? data.personalDetailsList?.[reportItem.managerID] : emptyPersonalDetails,
transactions,
...(reportPendingAction ? {pendingAction: reportPendingAction} : {}),
Expand Down Expand Up @@ -1495,10 +1502,10 @@ function getReportSections(
};
if (reportIDToTransactions[reportKey]?.transactions) {
reportIDToTransactions[reportKey].transactions.push(transaction);
reportIDToTransactions[reportKey].from = data.personalDetailsList[data?.[reportKey as ReportKey]?.accountID ?? CONST.DEFAULT_NUMBER_ID];
reportIDToTransactions[reportKey].from = data.personalDetailsList[data?.[reportKey as ReportKey]?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID];
} else if (reportIDToTransactions[reportKey]) {
reportIDToTransactions[reportKey].transactions = [transaction];
reportIDToTransactions[reportKey].from = data.personalDetailsList[data?.[reportKey as ReportKey]?.accountID ?? CONST.DEFAULT_NUMBER_ID];
reportIDToTransactions[reportKey].from = data.personalDetailsList[data?.[reportKey as ReportKey]?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID];
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/types/onyx/SearchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ type SearchPersonalDetails = {
/** The action that can be performed for the transaction */
type SearchTransactionAction = ValueOf<typeof CONST.SEARCH.ACTION_TYPES>;

/** Model of report search result */
/** Model of report search result
*
* @deprecated - Use Report instead
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@s77rt This PR is causing error lint on other PRs because we missed adding a command to disable the lint rule in other usage of this type

// eslint-disable-next-line @typescript-eslint/no-deprecated

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah noticing this too, is there any follow-up changes we need to make here? Or was it intended to make other PRs that make any changes to a file that uses SearchReport fail?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of failing ones are being handled or handled already. For the rest you can just add above comment to disable the lint. This is deprecated so no new usage is introduced but for current usage ignoring the lint is fine.

*/
type SearchReport = {
/** The ID of the report */
reportID: string;
Expand All @@ -107,9 +110,6 @@ type SearchReport = {
/** The accountID of the report manager */
managerID?: number;

/** The accountID of the user who created the report */
accountID?: number;

/** The policyID of the report */
policyID?: string;

Expand Down Expand Up @@ -558,6 +558,7 @@ type SearchResults = {
data: PrefixedRecord<typeof ONYXKEYS.COLLECTION.TRANSACTION, SearchTransaction> &
Record<typeof ONYXKEYS.PERSONAL_DETAILS_LIST, Record<string, SearchPersonalDetails>> &
PrefixedRecord<typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS, Record<string, SearchReportAction>> &
// eslint-disable-next-line @typescript-eslint/no-deprecated
PrefixedRecord<typeof ONYXKEYS.COLLECTION.REPORT, SearchReport> &
PrefixedRecord<typeof ONYXKEYS.COLLECTION.POLICY, SearchPolicy> &
PrefixedRecord<typeof ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, TransactionViolation[]> &
Expand All @@ -582,6 +583,7 @@ export type {
SearchTransactionAction,
SearchPersonalDetails,
SearchDataTypes,
// eslint-disable-next-line @typescript-eslint/no-deprecated
SearchReport,
SearchReportAction,
SearchPolicy,
Expand Down
1 change: 0 additions & 1 deletion tests/unit/Search/SearchUIUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2510,7 +2510,6 @@ describe('SearchUIUtils', () => {
},
// eslint-disable-next-line @typescript-eslint/naming-convention
report_6523565988285061: {
accountID: 2074551,
chatReportID: '4128157185472356',
created: '2025-05-26 19:49:56',
currency: 'USD',
Expand Down
Loading