From ea16393658d14e6969b0fe000f4dd0422641c50d Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 27 Mar 2025 11:51:55 +0700 Subject: [PATCH] fix: Hidden shown in the To field in the reports page on draft open reports created --- src/libs/SearchUIUtils.ts | 13 +- tests/unit/Search/SearchUIUtilsTest.ts | 922 +------------------------ 2 files changed, 27 insertions(+), 908 deletions(-) diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index f515b55a00a47..c1f2c48ca9afe 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -46,6 +46,7 @@ import { isClosedReport, isInvoiceReport, isMoneyRequestReport, + isOpenExpenseReport, isSettled, } from './ReportUtils'; import {buildCannedSearchQuery} from './SearchQueryUtils'; @@ -283,8 +284,10 @@ function getTransactionsSections(data: OnyxTypes.SearchResults['data'], metadata .filter(isTransactionEntry) .map((key) => { const transactionItem = data[key]; + const report = data[`${ONYXKEYS.COLLECTION.REPORT}${transactionItem.reportID}`]; + const shouldShowBlankTo = isOpenExpenseReport(report); const from = data.personalDetailsList?.[transactionItem.accountID]; - const to = transactionItem.managerID ? data.personalDetailsList?.[transactionItem.managerID] : emptyPersonalDetails; + const to = transactionItem.managerID && !shouldShowBlankTo ? data.personalDetailsList?.[transactionItem.managerID] : emptyPersonalDetails; const {formattedFrom, formattedTo, formattedTotal, formattedMerchant, date} = getTransactionItemCommonFormattedProperties(transactionItem, from, to); @@ -294,7 +297,7 @@ function getTransactionsSections(data: OnyxTypes.SearchResults['data'], metadata from, to, formattedFrom, - formattedTo, + formattedTo: shouldShowBlankTo ? '' : formattedTo, formattedTotal, formattedMerchant, date, @@ -483,9 +486,11 @@ function getReportSections(data: OnyxTypes.SearchResults['data'], metadata: Onyx } else if (isTransactionEntry(key)) { const transactionItem = {...data[key]}; const reportKey = `${ONYXKEYS.COLLECTION.REPORT}${transactionItem.reportID}`; + const report = data[`${ONYXKEYS.COLLECTION.REPORT}${transactionItem.reportID}`]; + const shouldShowBlankTo = isOpenExpenseReport(report); const from = data.personalDetailsList?.[transactionItem.accountID]; - const to = transactionItem.managerID ? data.personalDetailsList?.[transactionItem.managerID] : emptyPersonalDetails; + const to = transactionItem.managerID && !shouldShowBlankTo ? data.personalDetailsList?.[transactionItem.managerID] : emptyPersonalDetails; const {formattedFrom, formattedTo, formattedTotal, formattedMerchant, date} = getTransactionItemCommonFormattedProperties(transactionItem, from, to); @@ -495,7 +500,7 @@ function getReportSections(data: OnyxTypes.SearchResults['data'], metadata: Onyx from, to, formattedFrom, - formattedTo, + formattedTo: shouldShowBlankTo ? '' : formattedTo, formattedTotal, formattedMerchant, date, diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index c342a28792e0a..da7c656341270 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -123,8 +123,8 @@ const searchResults: OnyxTypes.SearchResults = { policyID, reportID, reportName: 'Expense Report #123', - stateNum: 1, - statusNum: 1, + stateNum: 0, + statusNum: 0, total: -5000, type: 'expense', unheldTotal: -5000, @@ -369,7 +369,7 @@ const transactionsListItems = [ description: '', formattedFrom: 'Admin', formattedMerchant: 'Expense', - formattedTo: 'Admin', + formattedTo: '', formattedTotal: 5000, from: { accountID: 18439984, @@ -398,10 +398,10 @@ const transactionsListItems = [ shouldShowYear: true, tag: '', to: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, + accountID: 0, + avatar: '', + displayName: undefined, + login: undefined, }, transactionID: '1', transactionThreadReportID: '456', @@ -587,8 +587,8 @@ const reportsListItems = [ policyID: 'A1B2C3', reportID: '123456789', reportName: 'Expense Report #123', - stateNum: 1, - statusNum: 1, + stateNum: 0, + statusNum: 0, to: { accountID: 18439984, avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', @@ -612,7 +612,7 @@ const reportsListItems = [ description: '', formattedFrom: 'Admin', formattedMerchant: 'Expense', - formattedTo: 'Admin', + formattedTo: '', formattedTotal: 5000, from: { accountID: 18439984, @@ -641,10 +641,10 @@ const reportsListItems = [ shouldShowYear: true, tag: '', to: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, + accountID: 0, + avatar: '', + displayName: undefined, + login: undefined, }, transactionID: '1', transactionThreadReportID: '456', @@ -884,905 +884,19 @@ describe('SearchUIUtils', () => { }); it('should return getSortedTransactionData result when shouldGroupByReports is false', () => { - expect(SearchUIUtils.getSortedSections(CONST.SEARCH.DATA_TYPES.EXPENSE, 'all', transactionsListItems, 'date', 'asc', false)).toStrictEqual([ - { - accountID: 18439984, - action: 'pay', - amount: -5000, - canDelete: true, - canHold: true, - canUnhold: false, - category: '', - comment: { - comment: '', - }, - created: '2024-12-21', - currency: 'USD', - date: '2024-12-21', - description: '', - formattedFrom: 'Admin', - formattedMerchant: 'Expense', - formattedTo: 'Admin', - formattedTotal: 5000, - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - hasEReceipt: false, - hasViolation: false, - isFromOneTransactionReport: true, - keyForList: '1', - managerID: 18439984, - merchant: 'Expense', - modifiedAmount: 0, - modifiedCreated: '', - modifiedCurrency: '', - modifiedMerchant: 'Expense', - parentTransactionID: '', - policyID: 'A1B2C3', - reportID: '123456789', - reportType: 'expense', - shouldShowCategory: true, - shouldShowMerchant: true, - shouldShowTag: false, - shouldShowTax: false, - shouldShowYear: true, - tag: '', - to: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - transactionID: '1', - transactionThreadReportID: '456', - transactionType: 'cash', - }, - { - accountID: 18439984, - action: 'review', - amount: -5000, - canDelete: true, - canHold: true, - canUnhold: false, - category: '', - comment: { - comment: '', - }, - created: '2024-12-21', - currency: 'USD', - date: '2024-12-21', - description: '', - formattedFrom: 'Admin', - formattedMerchant: 'Expense', - formattedTo: 'Admin', - formattedTotal: 5000, - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - hasEReceipt: false, - hasViolation: true, - isFromOneTransactionReport: true, - keyForList: '2', - managerID: 18439984, - merchant: 'Expense', - modifiedAmount: 0, - modifiedCreated: '', - modifiedCurrency: '', - modifiedMerchant: 'Expense', - parentTransactionID: '', - policyID: 'A1B2C3', - reportID: '11111', - reportType: 'expense', - shouldShowCategory: true, - shouldShowMerchant: true, - shouldShowTag: false, - shouldShowTax: false, - shouldShowYear: true, - tag: '', - to: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - transactionID: '2', - transactionThreadReportID: '456', - transactionType: 'cash', - }, - transactionsListItems.at(2), - transactionsListItems.at(3), - ]); + expect(SearchUIUtils.getSortedSections(CONST.SEARCH.DATA_TYPES.EXPENSE, 'all', transactionsListItems, 'date', 'asc', false)).toStrictEqual(transactionsListItems); }); it('should return getSortedReportData result when type is EXPENSE and shouldGroupByReports is true', () => { - expect(SearchUIUtils.getSortedSections(CONST.SEARCH.DATA_TYPES.EXPENSE, 'all', reportsListItems, 'date', 'asc', true)).toStrictEqual([ - { - accountID: 18439984, - chatReportID: '6155022250251839', - chatType: undefined, - created: '2025-03-05 16:34:27', - currency: 'VND', - isOneTransactionReport: false, - isOwnPolicyExpenseChat: false, - isPolicyExpenseChat: false, - isWaitingOnBankAccount: false, - managerID: 1111111, - nonReimbursableTotal: 0, - oldPolicyName: '', - ownerAccountID: 18439984, - policyID: 'A1B2C3', - private_isArchived: '', - reportID: '99999', - reportName: 'Approver owes ₫44.00', - stateNum: 1, - statusNum: 1, - total: 4400, - type: 'iou', - unheldTotal: 4400, - action: 'pay', - keyForList: '99999', - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: 'admin@policy.com', - }, - to: { - accountID: 1111111, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Approver', - login: 'approver@policy.com', - }, - transactions: [transactionsListItems.at(2), transactionsListItems.at(3)], - }, - { - accountID: 18439984, - action: 'pay', - chatReportID: '1706144653204915', - created: '2024-12-21 13:05:20', - currency: 'USD', - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - isOneTransactionReport: true, - isPolicyExpenseChat: false, - isWaitingOnBankAccount: false, - keyForList: '123456789', - managerID: 18439984, - nonReimbursableTotal: 0, - ownerAccountID: 18439984, - policyID: 'A1B2C3', - reportID: '123456789', - reportName: 'Expense Report #123', - stateNum: 1, - statusNum: 1, - to: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - total: -5000, - transactions: [ - { - accountID: 18439984, - action: 'pay', - amount: -5000, - canDelete: true, - canHold: true, - canUnhold: false, - category: '', - comment: { - comment: '', - }, - created: '2024-12-21', - currency: 'USD', - date: '2024-12-21', - description: '', - formattedFrom: 'Admin', - formattedMerchant: 'Expense', - formattedTo: 'Admin', - formattedTotal: 5000, - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - hasEReceipt: false, - hasViolation: false, - isFromOneTransactionReport: true, - keyForList: '1', - managerID: 18439984, - merchant: 'Expense', - modifiedAmount: 0, - modifiedCreated: '', - modifiedCurrency: '', - modifiedMerchant: 'Expense', - parentTransactionID: '', - policyID: 'A1B2C3', - reportID: '123456789', - reportType: 'expense', - shouldShowCategory: true, - shouldShowMerchant: true, - shouldShowTag: false, - shouldShowTax: false, - shouldShowYear: true, - tag: '', - to: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - transactionID: '1', - transactionThreadReportID: '456', - transactionType: 'cash', - }, - ], - type: 'expense', - unheldTotal: -5000, - }, - { - accountID: 18439984, - action: 'review', - chatReportID: '1706144653204915', - created: '2024-12-21 13:05:20', - currency: 'USD', - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - isOneTransactionReport: true, - isPolicyExpenseChat: false, - isWaitingOnBankAccount: false, - keyForList: '11111', - managerID: 18439984, - nonReimbursableTotal: 0, - ownerAccountID: 18439984, - policyID: 'A1B2C3', - reportID: '11111', - reportName: 'Expense Report #123', - stateNum: 1, - statusNum: 1, - to: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - total: -5000, - transactions: [ - { - accountID: 18439984, - action: 'review', - amount: -5000, - canDelete: true, - canHold: true, - canUnhold: false, - category: '', - comment: { - comment: '', - }, - created: '2024-12-21', - currency: 'USD', - date: '2024-12-21', - description: '', - formattedFrom: 'Admin', - formattedMerchant: 'Expense', - formattedTo: 'Admin', - formattedTotal: 5000, - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - hasEReceipt: false, - hasViolation: true, - isFromOneTransactionReport: true, - keyForList: '2', - managerID: 18439984, - merchant: 'Expense', - modifiedAmount: 0, - modifiedCreated: '', - modifiedCurrency: '', - modifiedMerchant: 'Expense', - parentTransactionID: '', - policyID: 'A1B2C3', - reportID: '11111', - reportType: 'expense', - shouldShowCategory: true, - shouldShowMerchant: true, - shouldShowTag: false, - shouldShowTax: false, - shouldShowYear: true, - tag: '', - to: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - transactionID: '2', - transactionThreadReportID: '456', - transactionType: 'cash', - }, - ], - type: 'expense', - unheldTotal: -5000, - }, - ]); + expect(SearchUIUtils.getSortedSections(CONST.SEARCH.DATA_TYPES.EXPENSE, 'all', reportsListItems, 'date', 'asc', true)).toStrictEqual(reportsListItems); }); it('should return getSortedReportData result when type is TRIP and shouldGroupByReports is true', () => { - expect(SearchUIUtils.getSortedSections(CONST.SEARCH.DATA_TYPES.TRIP, 'all', reportsListItems, 'date', 'asc', true)).toStrictEqual([ - { - accountID: 18439984, - chatReportID: '6155022250251839', - chatType: undefined, - created: '2025-03-05 16:34:27', - currency: 'VND', - isOneTransactionReport: false, - isOwnPolicyExpenseChat: false, - isPolicyExpenseChat: false, - isWaitingOnBankAccount: false, - managerID: 1111111, - nonReimbursableTotal: 0, - oldPolicyName: '', - ownerAccountID: 18439984, - policyID: 'A1B2C3', - private_isArchived: '', - reportID: '99999', - reportName: 'Approver owes ₫44.00', - stateNum: 1, - statusNum: 1, - total: 4400, - type: 'iou', - unheldTotal: 4400, - action: 'pay', - keyForList: '99999', - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: 'admin@policy.com', - }, - to: { - accountID: 1111111, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Approver', - login: 'approver@policy.com', - }, - transactions: [transactionsListItems.at(2), transactionsListItems.at(3)], - }, - { - accountID: 18439984, - action: 'pay', - chatReportID: '1706144653204915', - created: '2024-12-21 13:05:20', - currency: 'USD', - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - isOneTransactionReport: true, - isPolicyExpenseChat: false, - isWaitingOnBankAccount: false, - keyForList: '123456789', - managerID: 18439984, - nonReimbursableTotal: 0, - ownerAccountID: 18439984, - policyID: 'A1B2C3', - reportID: '123456789', - reportName: 'Expense Report #123', - stateNum: 1, - statusNum: 1, - to: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - total: -5000, - transactions: [ - { - accountID: 18439984, - action: 'pay', - amount: -5000, - canDelete: true, - canHold: true, - canUnhold: false, - category: '', - comment: { - comment: '', - }, - created: '2024-12-21', - currency: 'USD', - date: '2024-12-21', - description: '', - formattedFrom: 'Admin', - formattedMerchant: 'Expense', - formattedTo: 'Admin', - formattedTotal: 5000, - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - hasEReceipt: false, - hasViolation: false, - isFromOneTransactionReport: true, - keyForList: '1', - managerID: 18439984, - merchant: 'Expense', - modifiedAmount: 0, - modifiedCreated: '', - modifiedCurrency: '', - modifiedMerchant: 'Expense', - parentTransactionID: '', - policyID: 'A1B2C3', - reportID: '123456789', - reportType: 'expense', - shouldShowCategory: true, - shouldShowMerchant: true, - shouldShowTag: false, - shouldShowTax: false, - shouldShowYear: true, - tag: '', - to: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - transactionID: '1', - transactionThreadReportID: '456', - transactionType: 'cash', - }, - ], - type: 'expense', - unheldTotal: -5000, - }, - { - accountID: 18439984, - action: 'review', - chatReportID: '1706144653204915', - created: '2024-12-21 13:05:20', - currency: 'USD', - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - isOneTransactionReport: true, - isPolicyExpenseChat: false, - isWaitingOnBankAccount: false, - keyForList: '11111', - managerID: 18439984, - nonReimbursableTotal: 0, - ownerAccountID: 18439984, - policyID: 'A1B2C3', - reportID: '11111', - reportName: 'Expense Report #123', - stateNum: 1, - statusNum: 1, - to: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - total: -5000, - transactions: [ - { - accountID: 18439984, - action: 'review', - amount: -5000, - canDelete: true, - canHold: true, - canUnhold: false, - category: '', - comment: { - comment: '', - }, - created: '2024-12-21', - currency: 'USD', - date: '2024-12-21', - description: '', - formattedFrom: 'Admin', - formattedMerchant: 'Expense', - formattedTo: 'Admin', - formattedTotal: 5000, - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - hasEReceipt: false, - hasViolation: true, - isFromOneTransactionReport: true, - keyForList: '2', - managerID: 18439984, - merchant: 'Expense', - modifiedAmount: 0, - modifiedCreated: '', - modifiedCurrency: '', - modifiedMerchant: 'Expense', - parentTransactionID: '', - policyID: 'A1B2C3', - reportID: '11111', - reportType: 'expense', - shouldShowCategory: true, - shouldShowMerchant: true, - shouldShowTag: false, - shouldShowTax: false, - shouldShowYear: true, - tag: '', - to: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - transactionID: '2', - transactionThreadReportID: '456', - transactionType: 'cash', - }, - ], - type: 'expense', - unheldTotal: -5000, - }, - ]); + expect(SearchUIUtils.getSortedSections(CONST.SEARCH.DATA_TYPES.TRIP, 'all', reportsListItems, 'date', 'asc', true)).toStrictEqual(reportsListItems); }); it('should return getSortedReportData result when type is INVOICE and shouldGroupByReports is true', () => { - expect(SearchUIUtils.getSortedSections(CONST.SEARCH.DATA_TYPES.INVOICE, 'all', reportsListItems, 'date', 'asc', true)).toStrictEqual([ - { - accountID: 18439984, - chatReportID: '6155022250251839', - chatType: undefined, - created: '2025-03-05 16:34:27', - currency: 'VND', - isOneTransactionReport: false, - isOwnPolicyExpenseChat: false, - isPolicyExpenseChat: false, - isWaitingOnBankAccount: false, - managerID: 1111111, - nonReimbursableTotal: 0, - oldPolicyName: '', - ownerAccountID: 18439984, - policyID: 'A1B2C3', - private_isArchived: '', - reportID: '99999', - reportName: 'Approver owes ₫44.00', - stateNum: 1, - statusNum: 1, - total: 4400, - type: 'iou', - unheldTotal: 4400, - action: 'pay', - keyForList: '99999', - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: 'admin@policy.com', - }, - to: { - accountID: 1111111, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Approver', - login: 'approver@policy.com', - }, - transactions: [ - { - accountID: 18439984, - amount: 1200, - action: 'view', - canDelete: true, - canHold: true, - canUnhold: false, - category: '', - created: '2025-03-05', - currency: 'VND', - comment: { - comment: '', - }, - hasEReceipt: false, - isFromOneTransactionReport: false, - managerID: 1111111, - merchant: '(none)', - modifiedAmount: 0, - modifiedCreated: '', - modifiedCurrency: '', - modifiedMerchant: '', - parentTransactionID: '', - policyID: 'A1B2C3', - reportID: '99999', - reportType: 'iou', - tag: '', - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: 'admin@policy.com', - }, - to: { - accountID: 1111111, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Approver', - login: 'approver@policy.com', - }, - transactionID: '3', - transactionThreadReportID: '8287398995021380', - transactionType: 'cash', - formattedFrom: 'Admin', - formattedTo: 'Approver', - formattedTotal: 1200, - formattedMerchant: '', - date: '2025-03-05', - shouldShowMerchant: true, - shouldShowCategory: true, - shouldShowTag: false, - shouldShowTax: false, - keyForList: '3', - shouldShowYear: true, - }, - { - accountID: 18439984, - amount: 3200, - action: 'view', - canDelete: true, - canHold: true, - canUnhold: false, - category: '', - created: '2025-03-05', - currency: 'VND', - hasEReceipt: false, - isFromOneTransactionReport: false, - managerID: 1111111, - merchant: '(none)', - comment: { - comment: '', - }, - modifiedAmount: 0, - modifiedCreated: '', - modifiedCurrency: '', - modifiedMerchant: '', - parentTransactionID: '', - policyID: 'A1B2C3', - reportID: '99999', - reportType: 'iou', - tag: '', - transactionID: '3', - transactionThreadReportID: '1014872441234902', - transactionType: 'cash', - formattedFrom: 'Admin', - formattedTo: 'Approver', - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: 'admin@policy.com', - }, - to: { - accountID: 1111111, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Approver', - login: 'approver@policy.com', - }, - formattedTotal: 3200, - formattedMerchant: '', - date: '2025-03-05', - shouldShowMerchant: true, - shouldShowCategory: true, - shouldShowTag: false, - shouldShowTax: false, - keyForList: '3', - shouldShowYear: true, - }, - ], - }, - { - accountID: 18439984, - action: 'pay', - chatReportID: '1706144653204915', - created: '2024-12-21 13:05:20', - currency: 'USD', - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - isOneTransactionReport: true, - isPolicyExpenseChat: false, - isWaitingOnBankAccount: false, - keyForList: '123456789', - managerID: 18439984, - nonReimbursableTotal: 0, - ownerAccountID: 18439984, - policyID: 'A1B2C3', - reportID: '123456789', - reportName: 'Expense Report #123', - stateNum: 1, - statusNum: 1, - to: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - total: -5000, - transactions: [ - { - accountID: 18439984, - action: 'pay', - amount: -5000, - canDelete: true, - canHold: true, - canUnhold: false, - category: '', - comment: { - comment: '', - }, - created: '2024-12-21', - currency: 'USD', - date: '2024-12-21', - description: '', - formattedFrom: 'Admin', - formattedMerchant: 'Expense', - formattedTo: 'Admin', - formattedTotal: 5000, - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - hasEReceipt: false, - hasViolation: false, - isFromOneTransactionReport: true, - keyForList: '1', - managerID: 18439984, - merchant: 'Expense', - modifiedAmount: 0, - modifiedCreated: '', - modifiedCurrency: '', - modifiedMerchant: 'Expense', - parentTransactionID: '', - policyID: 'A1B2C3', - reportID: '123456789', - reportType: 'expense', - shouldShowCategory: true, - shouldShowMerchant: true, - shouldShowTag: false, - shouldShowTax: false, - shouldShowYear: true, - tag: '', - to: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - transactionID: '1', - transactionThreadReportID: '456', - transactionType: 'cash', - }, - ], - type: 'expense', - unheldTotal: -5000, - }, - { - accountID: 18439984, - action: 'review', - chatReportID: '1706144653204915', - created: '2024-12-21 13:05:20', - currency: 'USD', - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - isOneTransactionReport: true, - isPolicyExpenseChat: false, - isWaitingOnBankAccount: false, - keyForList: '11111', - managerID: 18439984, - nonReimbursableTotal: 0, - ownerAccountID: 18439984, - policyID: 'A1B2C3', - reportID: '11111', - reportName: 'Expense Report #123', - stateNum: 1, - statusNum: 1, - to: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - total: -5000, - transactions: [ - { - accountID: 18439984, - action: 'review', - amount: -5000, - canDelete: true, - canHold: true, - canUnhold: false, - category: '', - comment: { - comment: '', - }, - created: '2024-12-21', - currency: 'USD', - date: '2024-12-21', - description: '', - formattedFrom: 'Admin', - formattedMerchant: 'Expense', - formattedTo: 'Admin', - formattedTotal: 5000, - from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - hasEReceipt: false, - hasViolation: true, - isFromOneTransactionReport: true, - keyForList: '2', - managerID: 18439984, - merchant: 'Expense', - modifiedAmount: 0, - modifiedCreated: '', - modifiedCurrency: '', - modifiedMerchant: 'Expense', - parentTransactionID: '', - policyID: 'A1B2C3', - reportID: '11111', - reportType: 'expense', - shouldShowCategory: true, - shouldShowMerchant: true, - shouldShowTag: false, - shouldShowTax: false, - shouldShowYear: true, - tag: '', - to: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: adminEmail, - }, - transactionID: '2', - transactionThreadReportID: '456', - transactionType: 'cash', - }, - ], - type: 'expense', - unheldTotal: -5000, - }, - ]); + expect(SearchUIUtils.getSortedSections(CONST.SEARCH.DATA_TYPES.INVOICE, 'all', reportsListItems, 'date', 'asc', true)).toStrictEqual(reportsListItems); }); });