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: 2 additions & 0 deletions src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ function Search({
queryJSON,
isActionLoadingSet,
cardFeeds,
allTransactionViolations: violations,
});
return [filteredData1, filteredData1.length, allLength];
}, [
Expand All @@ -449,6 +450,7 @@ function Search({
isActionLoadingSet,
cardFeeds,
bankAccountList,
violations,
]);

useEffect(() => {
Expand Down
55 changes: 40 additions & 15 deletions src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ type TransactionMemberGroupSorting = ColumnSortMapping<TransactionMemberGroupLis
type TransactionCardGroupSorting = ColumnSortMapping<TransactionCardGroupListItemType>;
type TransactionWithdrawalIDGroupSorting = ColumnSortMapping<TransactionWithdrawalIDGroupListItemType>;

type GetReportSectionsParams = {
data: OnyxTypes.SearchResults['data'];
currentSearch: SearchKey;
currentAccountID: number | undefined;
currentUserEmail: string;
translate: LocalizedTranslate;
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'];
isActionLoadingSet: ReadonlySet<string> | undefined;
allTransactionViolations: OnyxCollection<OnyxTypes.TransactionViolation[]>;
bankAccountList: OnyxEntry<OnyxTypes.BankAccountList>;
reportActions?: Record<string, OnyxTypes.ReportAction[]>;
shouldSkipActionFiltering?: boolean;
};

const transactionColumnNamesToSortingProperty: TransactionSorting = {
[CONST.SEARCH.TABLE_COLUMNS.TO]: 'formattedTo' as const,
[CONST.SEARCH.TABLE_COLUMNS.FROM]: 'formattedFrom' as const,
Expand Down Expand Up @@ -362,6 +376,7 @@ type GetSectionsParams = {
queryJSON?: SearchQueryJSON;
isActionLoadingSet?: ReadonlySet<string>;
cardFeeds?: OnyxCollection<OnyxTypes.CardFeeds>;
allTransactionViolations?: OnyxCollection<OnyxTypes.TransactionViolation[]>;
shouldSkipActionFiltering?: boolean;
};

Expand Down Expand Up @@ -1701,18 +1716,19 @@ function getReportActionsSections(data: OnyxTypes.SearchResults['data']): [Repor
*
* Do not use directly, use only via `getSections()` facade.
*/
function getReportSections(
data: OnyxTypes.SearchResults['data'],
currentSearch: SearchKey,
currentAccountID: number | undefined,
currentUserEmail: string,
translate: LocalizedTranslate,
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'],
isActionLoadingSet: ReadonlySet<string> | undefined,
bankAccountList: OnyxEntry<OnyxTypes.BankAccountList>,
reportActions: Record<string, OnyxTypes.ReportAction[]> = {},
function getReportSections({
data,
currentSearch,
currentAccountID,
currentUserEmail,
translate,
formatPhoneNumber,
isActionLoadingSet,
allTransactionViolations,
bankAccountList,
reportActions = {},
shouldSkipActionFiltering = false,
): [TransactionGroupListItemType[], number] {
}: GetReportSectionsParams): [TransactionGroupListItemType[], number] {
const shouldShowMerchant = getShouldShowMerchant(data);

const {
Expand Down Expand Up @@ -1804,7 +1820,7 @@ function getReportSections(

const hasAnyViolationsForReport = hasAnyViolations(
reportItem.reportID,
allViolations,
allTransactionViolations ?? allViolations,
currentAccountID ?? CONST.DEFAULT_NUMBER_ID,
currentUserEmail,
allReportTransactions,
Expand All @@ -1813,7 +1829,14 @@ function getReportSections(
);
const hasVisibleViolationsForReport =
hasAnyViolationsForReport &&
ViolationsUtils.hasVisibleViolationsForUser(reportItem, allViolations, currentUserEmail, currentAccountID ?? CONST.DEFAULT_NUMBER_ID, policy, allReportTransactions);
ViolationsUtils.hasVisibleViolationsForUser(
reportItem,
allTransactionViolations ?? allViolations,
currentUserEmail,
currentAccountID ?? CONST.DEFAULT_NUMBER_ID,
policy,
allReportTransactions,
);

reportIDToTransactions[reportKey] = {
...reportItem,
Expand Down Expand Up @@ -2085,6 +2108,7 @@ function getSections({
queryJSON,
isActionLoadingSet,
cardFeeds,
allTransactionViolations,
shouldSkipActionFiltering,
}: GetSectionsParams) {
if (type === CONST.SEARCH.DATA_TYPES.CHAT) {
Expand All @@ -2095,18 +2119,19 @@ function getSections({
}

if (type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT) {
return getReportSections(
return getReportSections({
data,
currentSearch,
currentAccountID,
currentUserEmail,
translate,
formatPhoneNumber,
isActionLoadingSet,
allTransactionViolations,
bankAccountList,
reportActions,
shouldSkipActionFiltering,
);
});
}

if (groupBy) {
Expand Down
Loading