From cb6fb32a1eaf6dc21dacaf056914f40257495848 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Tue, 27 Jan 2026 10:39:57 -0800 Subject: [PATCH 01/26] Add groupby:week --- src/CONST/index.ts | 10 ++ src/components/Search/SearchList/index.tsx | 8 + src/components/Search/index.tsx | 55 +++++-- .../Search/TransactionGroupListItem.tsx | 15 ++ .../Search/WeekListItemHeader.tsx | 143 ++++++++++++++++++ .../SearchTableHeader.tsx | 18 +++ .../SelectionListWithSections/types.ts | 10 ++ src/languages/en.ts | 2 + src/libs/DateUtils.ts | 14 ++ src/libs/SearchUIUtils.ts | 105 +++++++++++-- src/styles/utils/index.ts | 1 + src/types/onyx/SearchResults.ts | 3 +- 12 files changed, 358 insertions(+), 26 deletions(-) create mode 100644 src/components/SelectionListWithSections/Search/WeekListItemHeader.tsx diff --git a/src/CONST/index.ts b/src/CONST/index.ts index a98466cd2b28..01e93b50767e 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -6843,6 +6843,7 @@ const CONST = { WITHDRAWAL_ID: 'withdrawal-id', CATEGORY: 'category', MONTH: 'month', + WEEK: 'week', }, get TYPE_CUSTOM_COLUMNS() { return { @@ -6929,6 +6930,11 @@ const CONST = { EXPENSES: this.TABLE_COLUMNS.GROUP_EXPENSES, TOTAL: this.TABLE_COLUMNS.GROUP_TOTAL, }, + WEEK: { + WEEK: this.TABLE_COLUMNS.GROUP_WEEK, + EXPENSES: this.TABLE_COLUMNS.GROUP_EXPENSES, + TOTAL: this.TABLE_COLUMNS.GROUP_TOTAL, + }, }; }, get TYPE_DEFAULT_COLUMNS() { @@ -6972,6 +6978,7 @@ const CONST = { ], CATEGORY: [this.TABLE_COLUMNS.GROUP_CATEGORY, this.TABLE_COLUMNS.GROUP_EXPENSES, this.TABLE_COLUMNS.GROUP_TOTAL], MONTH: [this.TABLE_COLUMNS.GROUP_MONTH, this.TABLE_COLUMNS.GROUP_EXPENSES, this.TABLE_COLUMNS.GROUP_TOTAL], + WEEK: [this.TABLE_COLUMNS.GROUP_WEEK, this.TABLE_COLUMNS.GROUP_EXPENSES, this.TABLE_COLUMNS.GROUP_TOTAL], }; }, BOOLEAN: { @@ -7069,6 +7076,7 @@ const CONST = { GROUP_WITHDRAWAL_ID: 'groupWithdrawalID', GROUP_CATEGORY: 'groupCategory', GROUP_MONTH: 'groupMonth', + GROUP_WEEK: 'groupWeek', }, SYNTAX_OPERATORS: { AND: 'and', @@ -7252,6 +7260,8 @@ const CONST = { [this.TABLE_COLUMNS.GROUP_WITHDRAWN]: 'group-withdrawn', [this.TABLE_COLUMNS.GROUP_WITHDRAWAL_ID]: 'group-withdrawal-id', [this.TABLE_COLUMNS.GROUP_CATEGORY]: 'group-category', + [this.TABLE_COLUMNS.GROUP_MONTH]: 'group-month', + [this.TABLE_COLUMNS.GROUP_WEEK]: 'group-week', }; }, NOT_MODIFIER: 'Not', diff --git a/src/components/Search/SearchList/index.tsx b/src/components/Search/SearchList/index.tsx index 3cecb2cdab92..45f7e6f4abfc 100644 --- a/src/components/Search/SearchList/index.tsx +++ b/src/components/Search/SearchList/index.tsx @@ -30,6 +30,7 @@ import type { TransactionGroupListItemType, TransactionListItemType, TransactionMonthGroupListItemType, + TransactionWeekGroupListItemType, } from '@components/SelectionListWithSections/types'; import Text from '@components/Text'; import useKeyboardState from '@hooks/useKeyboardState'; @@ -164,6 +165,13 @@ function isTransactionMatchWithGroupItem(transaction: Transaction, groupItem: Se const transactionDateString = transaction.modifiedCreated ?? transaction.created ?? ''; return DateUtils.isDateStringInMonth(transactionDateString, monthGroup.year, monthGroup.month); } + if (groupBy === CONST.SEARCH.GROUP_BY.WEEK) { + const weekGroup = groupItem as TransactionWeekGroupListItemType; + const transactionDateString = transaction.modifiedCreated ?? transaction.created ?? ''; + const datePart = transactionDateString.substring(0, 10); + const {start: weekStart, end: weekEnd} = DateUtils.getWeekDateRange(weekGroup.week); + return datePart >= weekStart && datePart <= weekEnd; + } return false; } diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 6a5baac052d5..2b48fae6abce 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -9,7 +9,7 @@ import FullPageErrorView from '@components/BlockingViews/FullPageErrorView'; import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView'; import ConfirmModal from '@components/ConfirmModal'; import SearchTableHeader from '@components/SelectionListWithSections/SearchTableHeader'; -import type {ReportActionListItemType, SearchListItem, SelectionListHandle, TransactionGroupListItemType, TransactionListItemType} from '@components/SelectionListWithSections/types'; +import type {ReportActionListItemType, SearchListItem, SelectionListHandle, TransactionGroupListItemType, TransactionListItemType, TransactionWeekGroupListItemType} from '@components/SelectionListWithSections/types'; import SearchRowSkeleton from '@components/Skeletons/SearchRowSkeleton'; import {WideRHPContext} from '@components/WideRHPContextProvider'; import useArchivedReportsIdSet from '@hooks/useArchivedReportsIdSet'; @@ -57,6 +57,7 @@ import { isTransactionListItemType, isTransactionMemberGroupListItemType, isTransactionMonthGroupListItemType, + isTransactionWeekGroupListItemType, isTransactionWithdrawalIDGroupListItemType, shouldShowEmptyState, shouldShowYear as shouldShowYearUtil, @@ -524,7 +525,7 @@ function Search({ // For expense reports: when ANY transaction is selected, we want ALL transactions in the report selected. // This ensures report-level selection persists when new transactions are added. - const hasAnySelected = isExpenseReportType && transactionGroup.transactions.some((transaction) => transaction.transactionID in selectedTransactions); + const hasAnySelected = isExpenseReportType && transactionGroup.transactions.some((transaction: TransactionListItemType) => transaction.transactionID in selectedTransactions); for (const transactionItem of transactionGroup.transactions) { const isSelected = transactionItem.transactionID in selectedTransactions; @@ -848,13 +849,42 @@ function Search({ return; } - let reportID = item.reportID; - if (isTransactionItem && item?.reportAction?.childReportID) { - const isFromSelfDM = item.reportID === CONST.REPORT.UNREPORTED_REPORT_ID; - const isFromOneTransactionReport = isOneTransactionReport(item.report); + if (isTransactionWeekGroupListItemType(item)) { + const weekGroupItem = item as TransactionWeekGroupListItemType; + const newFlatFilters = queryJSON.flatFilters.filter((filter) => filter.key !== CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE); + const {start: weekStart, end: weekEnd} = DateUtils.getWeekDateRange(weekGroupItem.week); + newFlatFilters.push({ + key: CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE, + filters: [ + {operator: CONST.SEARCH.SYNTAX_OPERATORS.GREATER_THAN_OR_EQUAL_TO, value: weekStart}, + {operator: CONST.SEARCH.SYNTAX_OPERATORS.LOWER_THAN_OR_EQUAL_TO, value: weekEnd}, + ], + }); + const newQueryJSON: SearchQueryJSON = {...queryJSON, groupBy: undefined, flatFilters: newFlatFilters}; + const newQuery = buildSearchQueryString(newQueryJSON); + const newQueryJSONWithHash = buildSearchQueryJSON(newQuery); + if (!newQueryJSONWithHash) { + return; + } + handleSearch({queryJSON: newQueryJSONWithHash, searchKey, offset: 0, shouldCalculateTotals: false, isLoading: false}); + return; + } + + // After handling all group types, item should be TransactionListItemType or ReportActionListItemType + if (!isTransactionItem && !isReportActionListItemType(item)) { + return; + } + + const transactionItem = item as TransactionListItemType; + const reportActionItem = item as ReportActionListItemType; + + let reportID = transactionItem.reportID ?? reportActionItem.reportID; + if (isTransactionItem && transactionItem?.reportAction?.childReportID) { + const isFromSelfDM = transactionItem.reportID === CONST.REPORT.UNREPORTED_REPORT_ID; + const isFromOneTransactionReport = isOneTransactionReport(transactionItem.report); if (isFromSelfDM || !isFromOneTransactionReport) { - reportID = item?.reportAction?.childReportID; + reportID = transactionItem?.reportAction?.childReportID; } } @@ -870,8 +900,9 @@ function Search({ }); if (isTransactionGroupListItemType(item)) { - const firstTransaction = item.transactions.at(0); - if (item.isOneTransactionReport && firstTransaction && transactionPreviewData) { + const groupItem = item as TransactionGroupListItemType; + const firstTransaction = groupItem.transactions.at(0); + if (groupItem.isOneTransactionReport && firstTransaction && transactionPreviewData) { if (!firstTransaction?.reportAction?.childReportID) { createAndOpenSearchTransactionThread(firstTransaction, backTo, firstTransaction?.reportAction?.childReportID, transactionPreviewData, false); } else { @@ -879,7 +910,7 @@ function Search({ } } - if (item.transactions.length > 1) { + if (groupItem.transactions.length > 1) { markReportIDAsMultiTransactionExpense(reportID); } else { unmarkReportIDAsMultiTransactionExpense(reportID); @@ -890,7 +921,7 @@ function Search({ } if (isReportActionListItemType(item)) { - const reportActionID = item.reportActionID; + const reportActionID = reportActionItem.reportActionID; Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID, reportActionID, backTo})); return; } @@ -898,7 +929,7 @@ function Search({ markReportIDAsExpense(reportID); if (isTransactionItem && transactionPreviewData) { - setOptimisticDataForTransactionThreadPreview(item, transactionPreviewData, item?.reportAction?.childReportID); + setOptimisticDataForTransactionThreadPreview(transactionItem, transactionPreviewData, transactionItem?.reportAction?.childReportID); } requestAnimationFrame(() => Navigation.navigate(ROUTES.SEARCH_REPORT.getRoute({reportID, backTo}))); diff --git a/src/components/SelectionListWithSections/Search/TransactionGroupListItem.tsx b/src/components/SelectionListWithSections/Search/TransactionGroupListItem.tsx index 58141afe9ce6..e3d69d186e31 100644 --- a/src/components/SelectionListWithSections/Search/TransactionGroupListItem.tsx +++ b/src/components/SelectionListWithSections/Search/TransactionGroupListItem.tsx @@ -20,6 +20,7 @@ import type { TransactionMemberGroupListItemType, TransactionMonthGroupListItemType, TransactionReportGroupListItemType, + TransactionWeekGroupListItemType, TransactionWithdrawalIDGroupListItemType, } from '@components/SelectionListWithSections/types'; import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle'; @@ -45,6 +46,7 @@ import CategoryListItemHeader from './CategoryListItemHeader'; import MemberListItemHeader from './MemberListItemHeader'; import MonthListItemHeader from './MonthListItemHeader'; import ReportListItemHeader from './ReportListItemHeader'; +import WeekListItemHeader from './WeekListItemHeader'; import TransactionGroupListExpandedItem from './TransactionGroupListExpanded'; import WithdrawalIDListItemHeader from './WithdrawalIDListItemHeader'; @@ -311,6 +313,19 @@ function TransactionGroupListItem({ isExpanded={isExpanded} /> ), + [CONST.SEARCH.GROUP_BY.WEEK]: ( + + ), }; if (searchType === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT) { diff --git a/src/components/SelectionListWithSections/Search/WeekListItemHeader.tsx b/src/components/SelectionListWithSections/Search/WeekListItemHeader.tsx new file mode 100644 index 000000000000..47e7e20d215c --- /dev/null +++ b/src/components/SelectionListWithSections/Search/WeekListItemHeader.tsx @@ -0,0 +1,143 @@ +import React from 'react'; +import {View} from 'react-native'; +import Checkbox from '@components/Checkbox'; +import type {SearchColumnType} from '@components/Search/types'; +import type {ListItem, TransactionWeekGroupListItemType} from '@components/SelectionListWithSections/types'; +import TextWithTooltip from '@components/TextWithTooltip'; +import useLocalize from '@hooks/useLocalize'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; +import useStyleUtils from '@hooks/useStyleUtils'; +import useThemeStyles from '@hooks/useThemeStyles'; +import DateUtils from '@libs/DateUtils'; +import CONST from '@src/CONST'; +import ExpandCollapseArrowButton from './ExpandCollapseArrowButton'; +import TextCell from './TextCell'; +import TotalCell from './TotalCell'; + +type WeekListItemHeaderProps = { + /** The week group currently being looked at */ + week: TransactionWeekGroupListItemType; + + /** Callback to fire when a checkbox is pressed */ + onCheckboxPress?: (item: TItem) => void; + + /** Whether this section items disabled for selection */ + isDisabled?: boolean | null; + + /** Whether selecting multiple transactions at once is allowed */ + canSelectMultiple: boolean | undefined; + + /** Whether all transactions are selected */ + isSelectAllChecked?: boolean; + + /** Whether only some transactions are selected */ + isIndeterminate?: boolean; + + /** Callback for when the down arrow is clicked */ + onDownArrowClick?: () => void; + + /** Whether the down arrow is expanded */ + isExpanded?: boolean; + + /** The visible columns for the header */ + columns?: SearchColumnType[]; +}; + +function WeekListItemHeader({ + week: weekItem, + onCheckboxPress, + isDisabled, + canSelectMultiple, + isSelectAllChecked, + isIndeterminate, + isExpanded, + onDownArrowClick, + columns, +}: WeekListItemHeaderProps) { + const styles = useThemeStyles(); + const StyleUtils = useStyleUtils(); + const {isLargeScreenWidth} = useResponsiveLayout(); + const {translate} = useLocalize(); + const weekName = weekItem.formattedWeek; + + const columnComponents = { + [CONST.SEARCH.TABLE_COLUMNS.GROUP_WEEK]: ( + + + + + + ), + [CONST.SEARCH.TABLE_COLUMNS.GROUP_EXPENSES]: ( + + + + ), + [CONST.SEARCH.TABLE_COLUMNS.GROUP_TOTAL]: ( + + + + ), + }; + + return ( + + + + {!!canSelectMultiple && ( + onCheckboxPress?.(weekItem as unknown as TItem)} + isChecked={isSelectAllChecked} + isIndeterminate={isIndeterminate} + disabled={!!isDisabled || weekItem.isDisabledCheckbox} + accessibilityLabel={translate('common.select')} + style={isLargeScreenWidth && styles.mr1} + /> + )} + {!isLargeScreenWidth && ( + + + + + + )} + {isLargeScreenWidth && columns?.map((column) => columnComponents[column as keyof typeof columnComponents])} + + {!isLargeScreenWidth && ( + + + {!!onDownArrowClick && ( + + )} + + )} + + + ); +} + +export default WeekListItemHeader; diff --git a/src/components/SelectionListWithSections/SearchTableHeader.tsx b/src/components/SelectionListWithSections/SearchTableHeader.tsx index 28092b9c9940..2ed2e1dce4b2 100644 --- a/src/components/SelectionListWithSections/SearchTableHeader.tsx +++ b/src/components/SelectionListWithSections/SearchTableHeader.tsx @@ -373,6 +373,24 @@ const getTransactionGroupHeaders = (groupBy: SearchGroupBy, icons: SearchHeaderI isColumnSortable: true, }, ]; + case CONST.SEARCH.GROUP_BY.WEEK: + return [ + { + columnName: CONST.SEARCH.TABLE_COLUMNS.GROUP_WEEK, + translationKey: 'common.week', + isColumnSortable: true, + }, + { + columnName: CONST.SEARCH.TABLE_COLUMNS.GROUP_EXPENSES, + translationKey: 'common.expenses', + isColumnSortable: true, + }, + { + columnName: CONST.SEARCH.TABLE_COLUMNS.GROUP_TOTAL, + translationKey: 'common.total', + isColumnSortable: true, + }, + ]; default: return []; } diff --git a/src/components/SelectionListWithSections/types.ts b/src/components/SelectionListWithSections/types.ts index 07d5688dfc8c..6e40708b6c15 100644 --- a/src/components/SelectionListWithSections/types.ts +++ b/src/components/SelectionListWithSections/types.ts @@ -36,6 +36,7 @@ import type { SearchMonthGroup, SearchTask, SearchTransactionAction, + SearchWeekGroup, SearchWithdrawalIDGroup, } from '@src/types/onyx/SearchResults'; import type {ReceiptErrors} from '@src/types/onyx/Transaction'; @@ -511,6 +512,14 @@ type TransactionCategoryGroupListItemType = TransactionGroupListItemType & {grou formattedCategory?: string; }; +type TransactionWeekGroupListItemType = TransactionGroupListItemType & {groupedBy: typeof CONST.SEARCH.GROUP_BY.WEEK} & SearchWeekGroup & { + /** Final and formatted "week" value used for displaying */ + formattedWeek: string; + + /** Key used for sorting */ + sortKey: string; + }; + type ListItemProps = CommonListItemProps & { /** The section list item */ item: TItem; @@ -1154,6 +1163,7 @@ export type { TransactionCardGroupListItemType, TransactionWithdrawalIDGroupListItemType, TransactionCategoryGroupListItemType, + TransactionWeekGroupListItemType, Section, SectionListDataType, SectionWithIndexOffset, diff --git a/src/languages/en.ts b/src/languages/en.ts index 3fbedbcf5a3c..d3c9e193f1ac 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -630,6 +630,7 @@ const translations = { reimbursableTotal: 'Reimbursable total', nonReimbursableTotal: 'Non-reimbursable total', month: 'Month', + week: 'Week', }, supportalNoAccess: { title: 'Not so fast', @@ -6822,6 +6823,7 @@ const translations = { [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'Withdrawal ID', [CONST.SEARCH.GROUP_BY.CATEGORY]: 'Category', [CONST.SEARCH.GROUP_BY.MONTH]: 'Month', + [CONST.SEARCH.GROUP_BY.WEEK]: 'Week', }, feed: 'Feed', withdrawalType: { diff --git a/src/libs/DateUtils.ts b/src/libs/DateUtils.ts index 8b5341ae2d4e..2e35f9b2d4b3 100644 --- a/src/libs/DateUtils.ts +++ b/src/libs/DateUtils.ts @@ -928,6 +928,19 @@ function getMonthDateRange(year: number, month: number): {start: string; end: st }; } +/** + * Returns the start and end dates of a week in the format yyyy-MM-dd. + * @param weekStartDate - Week start date string in YYYY-MM-DD format + */ +function getWeekDateRange(weekStartDate: string): {start: string; end: string} { + const weekStart = new Date(weekStartDate); + const weekEnd = endOfWeek(weekStart, {weekStartsOn: CONST.WEEK_STARTS_ON}); + return { + start: format(weekStart, 'yyyy-MM-dd'), + end: format(weekEnd, 'yyyy-MM-dd'), + }; +} + /** * Checks if a date string (yyyy-MM-dd or yyyy-MM-dd HH:mm:ss) falls within a specific month. * Uses string comparison to avoid timezone issues. @@ -1003,6 +1016,7 @@ const DateUtils = { isCurrentTimeWithinRange, formatInTimeZoneWithFallback, getMonthDateRange, + getWeekDateRange, isDateStringInMonth, }; diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 2c4d4f409bfa..0c39f8bcad53 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -1,4 +1,4 @@ -import {format} from 'date-fns'; +import {endOfWeek, format} from 'date-fns'; import type {TextStyle, ViewStyle} from 'react-native'; import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; @@ -39,6 +39,7 @@ import type { TransactionMemberGroupListItemType, TransactionMonthGroupListItemType, TransactionReportGroupListItemType, + TransactionWeekGroupListItemType, TransactionWithdrawalIDGroupListItemType, } from '@components/SelectionListWithSections/types'; import type {ThemeColors} from '@styles/theme/types'; @@ -935,6 +936,10 @@ function isTransactionMonthGroupListItemType(item: ListItem): item is Transactio return isTransactionGroupListItemType(item) && 'groupedBy' in item && item.groupedBy === CONST.SEARCH.GROUP_BY.MONTH; } +function isTransactionWeekGroupListItemType(item: ListItem): item is TransactionWeekGroupListItemType { + return isTransactionGroupListItemType(item) && 'groupedBy' in item && item.groupedBy === CONST.SEARCH.GROUP_BY.WEEK; +} + /** * Type guard that checks if something is a TransactionListItemType */ @@ -2236,6 +2241,58 @@ function getMonthSections(data: OnyxTypes.SearchResults['data'], queryJSON: Sear return [monthSectionsValues, monthSectionsValues.length]; } +/** + * Returns sections for week-grouped search results. + * Do not use directly, use only via `getSections()` facade. + */ +function getWeekSections(data: OnyxTypes.SearchResults['data'], queryJSON: SearchQueryJSON | undefined): [TransactionWeekGroupListItemType[], number] { + const weekSections: Record = {}; + for (const key in data) { + if (isGroupEntry(key)) { + const weekGroup = data[key]; + // Check if this is a week group by checking for week property + if (!('week' in weekGroup)) { + continue; + } + let transactionsQueryJSON: SearchQueryJSON | undefined; + if (queryJSON && weekGroup.week) { + // Create date range for the week (start date to end date of the week) + const weekStartDate = new Date(weekGroup.week); + const weekEndDate = endOfWeek(weekStartDate, {weekStartsOn: CONST.WEEK_STARTS_ON}); + const weekStart = format(weekStartDate, 'yyyy-MM-dd'); + const weekEnd = format(weekEndDate, 'yyyy-MM-dd'); + const newFlatFilters = queryJSON.flatFilters.filter((filter) => filter.key !== CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE); + newFlatFilters.push({ + key: CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE, + filters: [ + {operator: CONST.SEARCH.SYNTAX_OPERATORS.GREATER_THAN_OR_EQUAL_TO, value: weekStart}, + {operator: CONST.SEARCH.SYNTAX_OPERATORS.LOWER_THAN_OR_EQUAL_TO, value: weekEnd}, + ], + }); + const newQueryJSON: SearchQueryJSON = {...queryJSON, groupBy: undefined, flatFilters: newFlatFilters}; + const newQuery = buildSearchQueryString(newQueryJSON); + transactionsQueryJSON = buildSearchQueryJSON(newQuery); + } + + // Format week display: "Week of January 27, 2025" + const weekStartDate = new Date(weekGroup.week); + const formattedWeek = `Week of ${format(weekStartDate, 'MMMM d, yyyy')}`; + + weekSections[key] = { + groupedBy: CONST.SEARCH.GROUP_BY.WEEK, + transactions: [], + transactionsQueryJSON, + ...weekGroup, + formattedWeek, + sortKey: weekGroup.week, + }; + } + } + + const weekSectionsValues = Object.values(weekSections); + return [weekSectionsValues, weekSectionsValues.length]; +} + /** * Returns the appropriate list item component based on the type and status of the search data. */ @@ -2313,6 +2370,8 @@ function getSections({ return getCategorySections(data, queryJSON); case CONST.SEARCH.GROUP_BY.MONTH: return getMonthSections(data, queryJSON); + case CONST.SEARCH.GROUP_BY.WEEK: + return getWeekSections(data, queryJSON); } } @@ -3383,6 +3442,7 @@ function getColumnsToShow( [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: CONST.SEARCH.GROUP_CUSTOM_COLUMNS.WITHDRAWAL_ID, [CONST.SEARCH.GROUP_BY.CATEGORY]: CONST.SEARCH.GROUP_CUSTOM_COLUMNS.CATEGORY, [CONST.SEARCH.GROUP_BY.MONTH]: CONST.SEARCH.GROUP_CUSTOM_COLUMNS.MONTH, + [CONST.SEARCH.GROUP_BY.WEEK]: CONST.SEARCH.GROUP_CUSTOM_COLUMNS.WEEK, }[groupBy]; const defaultCustomColumns = { @@ -3391,22 +3451,23 @@ function getColumnsToShow( [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: CONST.SEARCH.GROUP_DEFAULT_COLUMNS.WITHDRAWAL_ID, [CONST.SEARCH.GROUP_BY.CATEGORY]: CONST.SEARCH.GROUP_DEFAULT_COLUMNS.CATEGORY, [CONST.SEARCH.GROUP_BY.MONTH]: CONST.SEARCH.GROUP_DEFAULT_COLUMNS.MONTH, + [CONST.SEARCH.GROUP_BY.WEEK]: CONST.SEARCH.GROUP_DEFAULT_COLUMNS.WEEK, }[groupBy]; - const filteredVisibleColumns = visibleColumns.filter((column) => Object.values(customColumns).includes(column as ValueOf)); - const columnsToShow = filteredVisibleColumns.length ? filteredVisibleColumns : defaultCustomColumns; + const filteredVisibleColumns = customColumns ? visibleColumns.filter((column) => Object.values(customColumns).includes(column as ValueOf)) : []; + const columnsToShow: SearchColumnType[] = filteredVisibleColumns.length ? filteredVisibleColumns : (defaultCustomColumns ?? []); if (groupBy === CONST.SEARCH.GROUP_BY.FROM) { const requiredColumns = new Set([CONST.SEARCH.TABLE_COLUMNS.AVATAR, CONST.SEARCH.TABLE_COLUMNS.GROUP_FROM]); const result: SearchColumnType[] = []; for (const col of requiredColumns) { - if (!columnsToShow.includes(col as SearchCustomColumnIds)) { + if (!(columnsToShow as SearchColumnType[]).includes(col)) { result.push(col); } } - for (const col of columnsToShow) { + for (const col of columnsToShow ?? []) { result.push(col); } @@ -3418,12 +3479,12 @@ function getColumnsToShow( const result: SearchColumnType[] = []; for (const col of requiredColumns) { - if (!columnsToShow.includes(col as SearchCustomColumnIds)) { + if (!(columnsToShow as SearchColumnType[]).includes(col)) { result.push(col); } } - for (const col of columnsToShow) { + for (const col of columnsToShow ?? []) { result.push(col); } @@ -3435,12 +3496,12 @@ function getColumnsToShow( const result: SearchColumnType[] = []; for (const col of requiredColumns) { - if (!columnsToShow.includes(col as SearchCustomColumnIds)) { + if (!(columnsToShow as SearchColumnType[]).includes(col)) { result.push(col); } } - for (const col of columnsToShow) { + for (const col of columnsToShow ?? []) { result.push(col); } @@ -3452,12 +3513,29 @@ function getColumnsToShow( const result: SearchColumnType[] = []; for (const col of requiredColumns) { - if (!columnsToShow.includes(col as SearchCustomColumnIds)) { + if (!(columnsToShow as SearchColumnType[]).includes(col)) { + result.push(col); + } + } + + for (const col of columnsToShow ?? []) { + result.push(col); + } + + return result; + } + + if (groupBy === CONST.SEARCH.GROUP_BY.WEEK) { + const requiredColumns = new Set([CONST.SEARCH.TABLE_COLUMNS.GROUP_WEEK]); + const result: SearchColumnType[] = []; + + for (const col of requiredColumns) { + if (!(columnsToShow as SearchColumnType[]).includes(col)) { result.push(col); } } - for (const col of columnsToShow) { + for (const col of columnsToShow ?? []) { result.push(col); } @@ -3469,12 +3547,12 @@ function getColumnsToShow( const result: SearchColumnType[] = []; for (const col of requiredColumns) { - if (!columnsToShow.includes(col as SearchCustomColumnIds)) { + if (!(columnsToShow as SearchColumnType[]).includes(col)) { result.push(col); } } - for (const col of columnsToShow) { + for (const col of columnsToShow ?? []) { result.push(col); } @@ -3764,6 +3842,7 @@ export { isTransactionWithdrawalIDGroupListItemType, isTransactionCategoryGroupListItemType, isTransactionMonthGroupListItemType, + isTransactionWeekGroupListItemType, isSearchResultsEmpty, isTransactionListItemType, isReportActionListItemType, diff --git a/src/styles/utils/index.ts b/src/styles/utils/index.ts index e3f1f221a33f..eb0622bea955 100644 --- a/src/styles/utils/index.ts +++ b/src/styles/utils/index.ts @@ -1765,6 +1765,7 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({ case CONST.SEARCH.TABLE_COLUMNS.CATEGORY: case CONST.SEARCH.TABLE_COLUMNS.GROUP_CATEGORY: case CONST.SEARCH.TABLE_COLUMNS.GROUP_MONTH: + case CONST.SEARCH.TABLE_COLUMNS.GROUP_WEEK: case CONST.SEARCH.TABLE_COLUMNS.TAG: columnWidth = {...getWidthStyle(variables.w36), ...styles.flex1}; break; diff --git a/src/types/onyx/SearchResults.ts b/src/types/onyx/SearchResults.ts index d2a30e31b84d..ece1865df8b9 100644 --- a/src/types/onyx/SearchResults.ts +++ b/src/types/onyx/SearchResults.ts @@ -219,7 +219,7 @@ type SearchResults = { PrefixedRecord & PrefixedRecord & PrefixedRecord & - PrefixedRecord; + PrefixedRecord; /** Whether search data is being fetched from server */ isLoading?: boolean; @@ -242,4 +242,5 @@ export type { SearchWithdrawalIDGroup, SearchCategoryGroup, SearchMonthGroup, + SearchWeekGroup, }; From 9dd115f29d89df978ef7bebd7a32cad40e6003bc Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Tue, 27 Jan 2026 11:59:24 -0800 Subject: [PATCH 02/26] Fix week groupping sorting --- src/CONST/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CONST/index.ts b/src/CONST/index.ts index d850d54b7694..edb1b9c01f81 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -7076,7 +7076,7 @@ const CONST = { GROUP_WITHDRAWAL_ID: 'groupWithdrawalID', GROUP_CATEGORY: 'groupCategory', GROUP_MONTH: 'groupmonth', - GROUP_WEEK: 'groupWeek', + GROUP_WEEK: 'groupweek', }, SYNTAX_OPERATORS: { AND: 'and', From 6ac4d62a3de967767f7940f455521c6fc24160a3 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Tue, 27 Jan 2026 14:46:27 -0800 Subject: [PATCH 03/26] Fix formatted week display --- src/libs/DateUtils.ts | 11 +++++++++++ src/libs/SearchUIUtils.ts | 5 ++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/libs/DateUtils.ts b/src/libs/DateUtils.ts index 2e35f9b2d4b3..9bd9a4aa42d2 100644 --- a/src/libs/DateUtils.ts +++ b/src/libs/DateUtils.ts @@ -957,6 +957,16 @@ function isDateStringInMonth(dateString: string, year: number, month: number): b return datePart >= monthStart && datePart <= monthEnd; } +/** + * Returns a formatted date range. + */ +function getFormattedDateRangeForSearch(startDate: Date, endDate: Date): string { + if (isSameYear(startDate, endDate)) { + return `${format(startDate, 'MMM d')} - ${format(endDate, 'MMM d, yyyy')}`; + } + return `${format(startDate, 'MMM d, yyyy')} - ${format(endDate, 'MMM d, yyyy')}`; +} + const DateUtils = { isDate, formatToDayOfWeek, @@ -1018,6 +1028,7 @@ const DateUtils = { getMonthDateRange, getWeekDateRange, isDateStringInMonth, + getFormattedDateRangeForSearch, }; export default DateUtils; diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index c729ebc5150d..c2bef028fd1d 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -1,4 +1,4 @@ -import {endOfWeek, format} from 'date-fns'; +import {addDays, endOfWeek, format} from 'date-fns'; import type {TextStyle, ViewStyle} from 'react-native'; import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; @@ -2283,9 +2283,8 @@ function getWeekSections(data: OnyxTypes.SearchResults['data'], queryJSON: Searc transactionsQueryJSON = buildSearchQueryJSON(newQuery); } - // Format week display: "Week of January 27, 2025" const weekStartDate = new Date(weekGroup.week); - const formattedWeek = `Week of ${format(weekStartDate, 'MMMM d, yyyy')}`; + const formattedWeek = DateUtils.getFormattedDateRangeForSearch(weekStartDate, addDays(weekStartDate, 6)); weekSections[key] = { groupedBy: CONST.SEARCH.GROUP_BY.WEEK, From 144834c4e526415dab554527d0abb8ae49d3ed36 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Tue, 27 Jan 2026 15:22:00 -0800 Subject: [PATCH 04/26] Fix expanding the week groups --- src/components/Search/index.tsx | 3 +++ src/libs/DateUtils.ts | 2 +- src/libs/SearchUIUtils.ts | 5 +---- src/types/onyx/SearchResults.ts | 15 +++++++++++++++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 1e8437cfd80f..04c57c290d34 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -862,6 +862,9 @@ function Search({ if (isTransactionWeekGroupListItemType(item)) { const weekGroupItem = item as TransactionWeekGroupListItemType; + if (!weekGroupItem.week) { + return; + } const newFlatFilters = queryJSON.flatFilters.filter((filter) => filter.key !== CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE); const {start: weekStart, end: weekEnd} = DateUtils.getWeekDateRange(weekGroupItem.week); newFlatFilters.push({ diff --git a/src/libs/DateUtils.ts b/src/libs/DateUtils.ts index 9bd9a4aa42d2..7df5e3a1c186 100644 --- a/src/libs/DateUtils.ts +++ b/src/libs/DateUtils.ts @@ -934,7 +934,7 @@ function getMonthDateRange(year: number, month: number): {start: string; end: st */ function getWeekDateRange(weekStartDate: string): {start: string; end: string} { const weekStart = new Date(weekStartDate); - const weekEnd = endOfWeek(weekStart, {weekStartsOn: CONST.WEEK_STARTS_ON}); + const weekEnd = addDays(weekStart, 6); return { start: format(weekStart, 'yyyy-MM-dd'), end: format(weekEnd, 'yyyy-MM-dd'), diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index c2bef028fd1d..a6b6bfa617cb 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -2266,10 +2266,7 @@ function getWeekSections(data: OnyxTypes.SearchResults['data'], queryJSON: Searc let transactionsQueryJSON: SearchQueryJSON | undefined; if (queryJSON && weekGroup.week) { // Create date range for the week (start date to end date of the week) - const weekStartDate = new Date(weekGroup.week); - const weekEndDate = endOfWeek(weekStartDate, {weekStartsOn: CONST.WEEK_STARTS_ON}); - const weekStart = format(weekStartDate, 'yyyy-MM-dd'); - const weekEnd = format(weekEndDate, 'yyyy-MM-dd'); + const {start: weekStart, end: weekEnd} = DateUtils.getWeekDateRange(weekGroup.week); const newFlatFilters = queryJSON.flatFilters.filter((filter) => filter.key !== CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE); newFlatFilters.push({ key: CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE, diff --git a/src/types/onyx/SearchResults.ts b/src/types/onyx/SearchResults.ts index ece1865df8b9..abf7a91dfafa 100644 --- a/src/types/onyx/SearchResults.ts +++ b/src/types/onyx/SearchResults.ts @@ -205,6 +205,21 @@ type SearchMonthGroup = { currency: string; }; +/** Model of week grouped search result */ +type SearchWeekGroup = { + /** Week start date in YYYY-MM-DD format */ + week: string; + + /** Number of transactions */ + count: number; + + /** Total value of transactions */ + total: number; + + /** Currency of total value */ + currency: string; +}; + /** Model of search results */ type SearchResults = { /** Current search results state */ From 3a57c8808bdd77a28ff2b403a0d09d5ca0dba960 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Tue, 27 Jan 2026 15:24:43 -0800 Subject: [PATCH 05/26] Prettier --- src/components/Search/index.tsx | 9 ++++++++- .../Search/TransactionGroupListItem.tsx | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 04c57c290d34..2364c863e2e3 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -9,7 +9,14 @@ import FullPageErrorView from '@components/BlockingViews/FullPageErrorView'; import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView'; import {ModalActions} from '@components/Modal/Global/ModalContext'; import SearchTableHeader from '@components/SelectionListWithSections/SearchTableHeader'; -import type {ReportActionListItemType, SearchListItem, SelectionListHandle, TransactionGroupListItemType, TransactionListItemType, TransactionWeekGroupListItemType} from '@components/SelectionListWithSections/types'; +import type { + ReportActionListItemType, + SearchListItem, + SelectionListHandle, + TransactionGroupListItemType, + TransactionListItemType, + TransactionWeekGroupListItemType, +} from '@components/SelectionListWithSections/types'; import SearchRowSkeleton from '@components/Skeletons/SearchRowSkeleton'; import {WideRHPContext} from '@components/WideRHPContextProvider'; import useArchivedReportsIdSet from '@hooks/useArchivedReportsIdSet'; diff --git a/src/components/SelectionListWithSections/Search/TransactionGroupListItem.tsx b/src/components/SelectionListWithSections/Search/TransactionGroupListItem.tsx index e3d69d186e31..6a16a266540c 100644 --- a/src/components/SelectionListWithSections/Search/TransactionGroupListItem.tsx +++ b/src/components/SelectionListWithSections/Search/TransactionGroupListItem.tsx @@ -46,8 +46,8 @@ import CategoryListItemHeader from './CategoryListItemHeader'; import MemberListItemHeader from './MemberListItemHeader'; import MonthListItemHeader from './MonthListItemHeader'; import ReportListItemHeader from './ReportListItemHeader'; -import WeekListItemHeader from './WeekListItemHeader'; import TransactionGroupListExpandedItem from './TransactionGroupListExpanded'; +import WeekListItemHeader from './WeekListItemHeader'; import WithdrawalIDListItemHeader from './WithdrawalIDListItemHeader'; function TransactionGroupListItem({ From 2ebab4cf1fc5723e85b338474227df75884c629b Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Tue, 27 Jan 2026 16:27:40 -0800 Subject: [PATCH 06/26] Fix week start and end dates --- src/libs/DateUtils.ts | 16 +++++++++++----- src/libs/SearchUIUtils.ts | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/libs/DateUtils.ts b/src/libs/DateUtils.ts index 7df5e3a1c186..9a512833eeaa 100644 --- a/src/libs/DateUtils.ts +++ b/src/libs/DateUtils.ts @@ -933,7 +933,11 @@ function getMonthDateRange(year: number, month: number): {start: string; end: st * @param weekStartDate - Week start date string in YYYY-MM-DD format */ function getWeekDateRange(weekStartDate: string): {start: string; end: string} { - const weekStart = new Date(weekStartDate); + // Parse the date string as a local date to avoid timezone issues + // Using parse with explicit format ensures it's treated as local time, not UTC + // This prevents dates like '2026-01-25' from being interpreted as UTC midnight + // which would shift to the previous day in timezones behind UTC (e.g., PST) + const weekStart = parse(weekStartDate, 'yyyy-MM-dd', new Date()); const weekEnd = addDays(weekStart, 6); return { start: format(weekStart, 'yyyy-MM-dd'), @@ -960,11 +964,13 @@ function isDateStringInMonth(dateString: string, year: number, month: number): b /** * Returns a formatted date range. */ -function getFormattedDateRangeForSearch(startDate: Date, endDate: Date): string { - if (isSameYear(startDate, endDate)) { - return `${format(startDate, 'MMM d')} - ${format(endDate, 'MMM d, yyyy')}`; +function getFormattedDateRangeForSearch(startDate: string, endDate: string): string { + const start = parse(startDate, 'yyyy-MM-dd', new Date()); + const end = parse(endDate, 'yyyy-MM-dd', new Date()); + if (isSameYear(new Date(start), new Date(end))) { + return `${format(start, 'MMM d')} - ${format(end, 'MMM d, yyyy')}`; } - return `${format(startDate, 'MMM d, yyyy')} - ${format(endDate, 'MMM d, yyyy')}`; + return `${format(start, 'MMM d, yyyy')} - ${format(end, 'MMM d, yyyy')}`; } const DateUtils = { diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index a6b6bfa617cb..e5f69584d826 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -2280,8 +2280,8 @@ function getWeekSections(data: OnyxTypes.SearchResults['data'], queryJSON: Searc transactionsQueryJSON = buildSearchQueryJSON(newQuery); } - const weekStartDate = new Date(weekGroup.week); - const formattedWeek = DateUtils.getFormattedDateRangeForSearch(weekStartDate, addDays(weekStartDate, 6)); + const {start: weekStart, end: weekEnd} = DateUtils.getWeekDateRange(weekGroup.week); + const formattedWeek = DateUtils.getFormattedDateRangeForSearch(weekStart, weekEnd); weekSections[key] = { groupedBy: CONST.SEARCH.GROUP_BY.WEEK, From af9eb565b76466c0d5b2d68b7cee34d49c464687 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Tue, 27 Jan 2026 16:38:37 -0800 Subject: [PATCH 07/26] Add translations --- src/languages/de.ts | 2 ++ src/languages/es.ts | 2 ++ src/languages/fr.ts | 2 ++ src/languages/it.ts | 2 ++ src/languages/ja.ts | 4 +++- src/languages/nl.ts | 2 ++ src/languages/pl.ts | 2 ++ src/languages/pt-BR.ts | 4 +++- src/languages/zh-hans.ts | 7 +++++-- 9 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/languages/de.ts b/src/languages/de.ts index 6c88f1680c3a..6fe752b8b902 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -638,6 +638,7 @@ const translations: TranslationDeepObject = { duplicateExpense: 'Doppelte Ausgabe', newFeature: 'Neue Funktion', month: 'Monat', + week: 'Woche', }, supportalNoAccess: { title: 'Nicht so schnell', @@ -6956,6 +6957,7 @@ Fordere Spesendetails wie Belege und Beschreibungen an, lege Limits und Standard [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'Auszahlungs-ID', [CONST.SEARCH.GROUP_BY.CATEGORY]: 'Kategorie', [CONST.SEARCH.GROUP_BY.MONTH]: 'Monat', + [CONST.SEARCH.GROUP_BY.WEEK]: 'Woche', }, feed: 'Feed', withdrawalType: { diff --git a/src/languages/es.ts b/src/languages/es.ts index 39b7468eb251..05e051822aad 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -389,6 +389,7 @@ const translations: TranslationDeepObject = { reimbursableTotal: 'Total reembolsable', nonReimbursableTotal: 'Total no reembolsable', month: 'Monat', + week: 'Semana', }, supportalNoAccess: { title: 'No tan rápido', @@ -6590,6 +6591,7 @@ ${amount} para ${merchant} - ${date}`, [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'ID de retiro', [CONST.SEARCH.GROUP_BY.CATEGORY]: 'Categoría', [CONST.SEARCH.GROUP_BY.MONTH]: 'Mes', + [CONST.SEARCH.GROUP_BY.WEEK]: 'Semana', }, feed: 'Feed', withdrawalType: { diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 7f08b0533309..d2f21ef9cf72 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -640,6 +640,7 @@ const translations: TranslationDeepObject = { duplicateExpense: 'Note de frais en double', newFeature: 'Nouvelle fonctionnalité', month: 'Mois', + week: 'Semaine', }, supportalNoAccess: { title: 'Pas si vite', @@ -6967,6 +6968,7 @@ Exigez des informations de dépense comme les reçus et les descriptions, défin [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'ID de retrait', [CONST.SEARCH.GROUP_BY.CATEGORY]: 'Catégorie', [CONST.SEARCH.GROUP_BY.MONTH]: 'Mois', + [CONST.SEARCH.GROUP_BY.WEEK]: 'Semaine', }, feed: 'Flux', withdrawalType: { diff --git a/src/languages/it.ts b/src/languages/it.ts index 7525885d0680..52b6b8ce2dbd 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -639,6 +639,7 @@ const translations: TranslationDeepObject = { duplicateExpense: 'Spesa duplicata', newFeature: 'Nuova funzionalità', month: 'Mese', + week: 'Settimana', }, supportalNoAccess: { title: 'Non così in fretta', @@ -6945,6 +6946,7 @@ Richiedi dettagli di spesa come ricevute e descrizioni, imposta limiti e valori [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'ID prelievo', //_/\__/_/ \_,_/\__/\__/\_,_/ [CONST.SEARCH.GROUP_BY.CATEGORY]: 'Categoria', [CONST.SEARCH.GROUP_BY.MONTH]: 'Mese', + [CONST.SEARCH.GROUP_BY.WEEK]: 'Settimana', }, feed: 'Feed', withdrawalType: { diff --git a/src/languages/ja.ts b/src/languages/ja.ts index 43f10ab5574e..789bba5b279d 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -638,6 +638,7 @@ const translations: TranslationDeepObject = { duplicateExpense: '重複した経費', newFeature: '新機能', month: '月', + week: '週', }, supportalNoAccess: { title: 'ちょっと待ってください', @@ -6882,9 +6883,10 @@ ${reportName} groupBy: { [CONST.SEARCH.GROUP_BY.FROM]: '差出人', [CONST.SEARCH.GROUP_BY.CARD]: 'カード', - [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: '出金ID', + [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: '出金 ID', [CONST.SEARCH.GROUP_BY.CATEGORY]: 'カテゴリ', [CONST.SEARCH.GROUP_BY.MONTH]: '月', + [CONST.SEARCH.GROUP_BY.WEEK]: '週', }, feed: 'フィード', withdrawalType: { diff --git a/src/languages/nl.ts b/src/languages/nl.ts index 5289966a8752..900a0d206147 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -639,6 +639,7 @@ const translations: TranslationDeepObject = { duplicateExpense: 'Dubbele uitgave', newFeature: 'Nieuwe functie', month: 'Maand', + week: 'Week', }, supportalNoAccess: { title: 'Niet zo snel', @@ -6927,6 +6928,7 @@ Vraag verplichte uitgavedetails zoals bonnetjes en beschrijvingen, stel limieten [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'Opname-ID', [CONST.SEARCH.GROUP_BY.CATEGORY]: 'Categorie', [CONST.SEARCH.GROUP_BY.MONTH]: 'Maand', + [CONST.SEARCH.GROUP_BY.WEEK]: 'Week', }, feed: 'Feed', withdrawalType: { diff --git a/src/languages/pl.ts b/src/languages/pl.ts index a37726567c98..307f5200c684 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -639,6 +639,7 @@ const translations: TranslationDeepObject = { duplicateExpense: 'Zduplikowany wydatek', newFeature: 'Nowa funkcja', month: 'Miesiąc', + week: 'Tydzień', }, supportalNoAccess: { title: 'Nie tak szybko', @@ -6917,6 +6918,7 @@ Wymagaj szczegółów wydatków, takich jak paragony i opisy, ustawiaj limity i [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'ID wypłaty', [CONST.SEARCH.GROUP_BY.CATEGORY]: 'Kategoria', [CONST.SEARCH.GROUP_BY.MONTH]: 'Miesiąc', + [CONST.SEARCH.GROUP_BY.WEEK]: 'Tydzień', }, feed: 'Kanał', withdrawalType: { diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index ee7cd0e6e336..55737c17f309 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -638,6 +638,7 @@ const translations: TranslationDeepObject = { duplicateExpense: 'Despesa duplicada', newFeature: 'Novo recurso', month: 'Mês', + week: 'Semana', }, supportalNoAccess: { title: 'Não tão rápido', @@ -6915,9 +6916,10 @@ Exija detalhes de despesas como recibos e descrições, defina limites e padrõe groupBy: { [CONST.SEARCH.GROUP_BY.FROM]: 'De', [CONST.SEARCH.GROUP_BY.CARD]: 'Cartão', - [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'ID de retirada', + [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'ID de saque', [CONST.SEARCH.GROUP_BY.CATEGORY]: 'Categoria', [CONST.SEARCH.GROUP_BY.MONTH]: 'Mês', + [CONST.SEARCH.GROUP_BY.WEEK]: 'Semana', }, feed: 'Feed', withdrawalType: { diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index ee322f52c2c7..e70328a2bb1c 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -635,6 +635,7 @@ const translations: TranslationDeepObject = { duplicateExpense: '重复报销', newFeature: '新功能', month: '月', + week: '周', }, supportalNoAccess: { title: '先别急', @@ -6760,11 +6761,13 @@ ${reportName} reimbursable: '可报销', purchaseCurrency: '购买货币', groupBy: { - [CONST.SEARCH.GROUP_BY.FROM]: '来自', + [CONST.SEARCH.GROUP_BY.FROM]: '发件人', [CONST.SEARCH.GROUP_BY.CARD]: '卡', - [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: '提现 ID', + //_/\__/_/ \_,_/\__/\__/\_,_/ + [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: '提现编号', [CONST.SEARCH.GROUP_BY.CATEGORY]: '类别', [CONST.SEARCH.GROUP_BY.MONTH]: '月', + [CONST.SEARCH.GROUP_BY.WEEK]: '周', }, feed: '动态', withdrawalType: { From baa97ba8d02f9d72abee09c75e283d60f9c97464 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Tue, 27 Jan 2026 16:49:20 -0800 Subject: [PATCH 08/26] UI test --- tests/ui/WeekListItemHeaderTest.tsx | 320 ++++++++++++++++++++++++++++ 1 file changed, 320 insertions(+) create mode 100644 tests/ui/WeekListItemHeaderTest.tsx diff --git a/tests/ui/WeekListItemHeaderTest.tsx b/tests/ui/WeekListItemHeaderTest.tsx new file mode 100644 index 000000000000..0bf16b23187f --- /dev/null +++ b/tests/ui/WeekListItemHeaderTest.tsx @@ -0,0 +1,320 @@ +import {act, fireEvent, render, screen} from '@testing-library/react-native'; +import React from 'react'; +import Onyx from 'react-native-onyx'; +import ComposeProviders from '@components/ComposeProviders'; +import {LocaleContextProvider} from '@components/LocaleContextProvider'; +import OnyxListItemProvider from '@components/OnyxListItemProvider'; +import {SearchContext} from '@components/Search/SearchContext'; +import type {SearchColumnType} from '@components/Search/types'; +import WeekListItemHeader from '@components/SelectionListWithSections/Search/WeekListItemHeader'; +import type {TransactionWeekGroupListItemType} from '@components/SelectionListWithSections/types'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'; + +jest.mock('@components/ConfirmedRoute.tsx'); +jest.mock('@libs/Navigation/Navigation'); + +// Mock useResponsiveLayout to control screen size in tests +jest.mock('@hooks/useResponsiveLayout', () => jest.fn()); +const mockedUseResponsiveLayout = useResponsiveLayout as jest.MockedFunction; + +// Mock search context with all required SearchContextProps fields +const mockSearchContext = { + currentSearchHash: 12345, + currentSearchKey: undefined, + currentSearchQueryJSON: undefined, + currentSearchResults: undefined, + selectedReports: [], + selectedTransactionIDs: [], + selectedTransactions: {}, + isOnSearch: false, + shouldTurnOffSelectionMode: false, + shouldResetSearchQuery: false, + lastSearchType: undefined, + areAllMatchingItemsSelected: false, + showSelectAllMatchingItems: false, + shouldShowFiltersBarLoading: false, + shouldUseLiveData: false, + setLastSearchType: jest.fn(), + setCurrentSearchHashAndKey: jest.fn(), + setCurrentSearchQueryJSON: jest.fn(), + setSelectedTransactions: jest.fn(), + removeTransaction: jest.fn(), + clearSelectedTransactions: jest.fn(), + setShouldShowFiltersBarLoading: jest.fn(), + shouldShowSelectAllMatchingItems: jest.fn(), + selectAllMatchingItems: jest.fn(), + setShouldResetSearchQuery: jest.fn(), +}; + +const createWeekListItem = (week: string, options: Partial = {}): TransactionWeekGroupListItemType => ({ + week, + formattedWeek: options.formattedWeek ?? 'Jan 25 - Jan 31, 2026', + count: options.count ?? 5, + currency: options.currency ?? 'USD', + total: options.total ?? 250, + groupedBy: CONST.SEARCH.GROUP_BY.WEEK, + transactions: [], + transactionsQueryJSON: undefined, + keyForList: `week-${week}`, + sortKey: options.sortKey ?? week, + ...options, +}); + +// Helper function to wrap component with context +const renderWeekListItemHeader = ( + weekItem: TransactionWeekGroupListItemType, + props: Partial<{ + onCheckboxPress: jest.Mock; + isDisabled: boolean; + canSelectMultiple: boolean; + isSelectAllChecked: boolean; + isIndeterminate: boolean; + onDownArrowClick: jest.Mock; + isExpanded: boolean; + columns: SearchColumnType[]; + }> = {}, +) => { + return render( + + + + + , + ); +}; + +describe('WeekListItemHeader', () => { + beforeAll(() => + Onyx.init({ + keys: ONYXKEYS, + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + }), + ); + + beforeEach(() => { + // Default to small screen (mobile) layout + mockedUseResponsiveLayout.mockReturnValue({ + isLargeScreenWidth: false, + shouldUseNarrowLayout: true, + isSmallScreenWidth: true, + isMediumScreenWidth: false, + isExtraSmallScreenWidth: false, + isExtraSmallScreenHeight: false, + isExtraLargeScreenWidth: false, + isSmallScreen: true, + isInNarrowPaneModal: false, + onboardingIsMediumOrLargerScreenWidth: false, + }); + }); + + afterEach(async () => { + await act(async () => { + await Onyx.clear(); + }); + jest.clearAllMocks(); + }); + + describe('Week display', () => { + it('should display the formatted week', async () => { + const weekItem = createWeekListItem('2026-01-25', {formattedWeek: 'Jan 25 - Jan 31, 2026'}); + renderWeekListItemHeader(weekItem); + await waitForBatchedUpdatesWithAct(); + + expect(screen.getByText('Jan 25 - Jan 31, 2026')).toBeOnTheScreen(); + }); + + it('should display different weeks correctly', async () => { + const weekItem = createWeekListItem('2025-12-28', {formattedWeek: 'Dec 28, 2025 - Jan 3, 2026'}); + renderWeekListItemHeader(weekItem); + await waitForBatchedUpdatesWithAct(); + + expect(screen.getByText('Dec 28, 2025 - Jan 3, 2026')).toBeOnTheScreen(); + }); + + it('should display week with different year', async () => { + const weekItem = createWeekListItem('2024-06-15', {formattedWeek: 'Jun 15 - Jun 21, 2024'}); + renderWeekListItemHeader(weekItem); + await waitForBatchedUpdatesWithAct(); + + expect(screen.getByText('Jun 15 - Jun 21, 2024')).toBeOnTheScreen(); + }); + }); + + describe('Checkbox functionality', () => { + it('should render checkbox when canSelectMultiple is true', async () => { + const weekItem = createWeekListItem('2026-01-25'); + renderWeekListItemHeader(weekItem, {canSelectMultiple: true}); + await waitForBatchedUpdatesWithAct(); + + expect(screen.getByRole('checkbox')).toBeOnTheScreen(); + }); + + it('should not render checkbox when canSelectMultiple is false', async () => { + const weekItem = createWeekListItem('2026-01-25'); + renderWeekListItemHeader(weekItem, {canSelectMultiple: false}); + await waitForBatchedUpdatesWithAct(); + + expect(screen.queryByRole('checkbox')).not.toBeOnTheScreen(); + }); + + it('should call onCheckboxPress when checkbox is pressed', async () => { + const onCheckboxPress = jest.fn(); + const weekItem = createWeekListItem('2026-01-25'); + renderWeekListItemHeader(weekItem, {canSelectMultiple: true, onCheckboxPress}); + await waitForBatchedUpdatesWithAct(); + + const checkbox = screen.getByRole('checkbox'); + fireEvent.press(checkbox); + + expect(onCheckboxPress).toHaveBeenCalledWith(weekItem); + }); + + it('should show checkbox as checked when isSelectAllChecked is true', async () => { + const weekItem = createWeekListItem('2026-01-25'); + renderWeekListItemHeader(weekItem, {canSelectMultiple: true, isSelectAllChecked: true}); + await waitForBatchedUpdatesWithAct(); + + expect(screen.getByRole('checkbox')).toBeChecked(); + }); + }); + + describe('Total and count display', () => { + it('should display the total amount', async () => { + const weekItem = createWeekListItem('2026-01-25', {total: 50000, currency: 'USD'}); + renderWeekListItemHeader(weekItem); + await waitForBatchedUpdatesWithAct(); + + // TotalCell formats the amount, so we check for the formatted version + // $500.00 is 50000 cents + expect(screen.getByText('$500.00')).toBeOnTheScreen(); + }); + + it('should display the total amount with different currencies', async () => { + const weekItem = createWeekListItem('2026-01-25', {total: 10000, currency: 'EUR'}); + renderWeekListItemHeader(weekItem); + await waitForBatchedUpdatesWithAct(); + + // Should display EUR formatted amount + expect(screen.getByTestId('TotalCell')).toBeOnTheScreen(); + }); + }); + + describe('Disabled state', () => { + it('should render checkbox with disabled styling when isDisabled is true', async () => { + const onCheckboxPress = jest.fn(); + const weekItem = createWeekListItem('2026-01-25'); + renderWeekListItemHeader(weekItem, {canSelectMultiple: true, isDisabled: true, onCheckboxPress}); + await waitForBatchedUpdatesWithAct(); + + const checkbox = screen.getByRole('checkbox'); + // The checkbox should still be rendered + expect(checkbox).toBeOnTheScreen(); + }); + + it('should render checkbox with disabled styling when isDisabledCheckbox is true on week item', async () => { + const onCheckboxPress = jest.fn(); + const weekItem = createWeekListItem('2026-01-25', {isDisabledCheckbox: true}); + renderWeekListItemHeader(weekItem, {canSelectMultiple: true, onCheckboxPress}); + await waitForBatchedUpdatesWithAct(); + + const checkbox = screen.getByRole('checkbox'); + // The checkbox should still be rendered + expect(checkbox).toBeOnTheScreen(); + }); + }); + + describe('Large screen layout', () => { + beforeEach(() => { + mockedUseResponsiveLayout.mockReturnValue({ + isLargeScreenWidth: true, + shouldUseNarrowLayout: false, + isSmallScreenWidth: false, + isMediumScreenWidth: false, + isExtraSmallScreenWidth: false, + isExtraSmallScreenHeight: false, + isExtraLargeScreenWidth: true, + isSmallScreen: false, + isInNarrowPaneModal: false, + onboardingIsMediumOrLargerScreenWidth: true, + }); + }); + + it('should render column components on large screen', async () => { + const weekItem = createWeekListItem('2026-01-25', {count: 5, total: 25000}); + renderWeekListItemHeader(weekItem, { + columns: [CONST.SEARCH.TABLE_COLUMNS.GROUP_WEEK, CONST.SEARCH.TABLE_COLUMNS.GROUP_EXPENSES, CONST.SEARCH.TABLE_COLUMNS.GROUP_TOTAL], + }); + await waitForBatchedUpdatesWithAct(); + + // Should display week name, expense count, and total + expect(screen.getByText('Jan 25 - Jan 31, 2026')).toBeOnTheScreen(); + expect(screen.getByText('5')).toBeOnTheScreen(); + expect(screen.getByText('$250.00')).toBeOnTheScreen(); + }); + + it('should render checkbox on large screen when canSelectMultiple is true', async () => { + const weekItem = createWeekListItem('2026-01-25'); + renderWeekListItemHeader(weekItem, {canSelectMultiple: true}); + await waitForBatchedUpdatesWithAct(); + + expect(screen.getByRole('checkbox')).toBeOnTheScreen(); + }); + }); + + describe('Expand/Collapse functionality', () => { + it('should render expand/collapse button when onDownArrowClick is provided', async () => { + const onDownArrowClick = jest.fn(); + const weekItem = createWeekListItem('2026-01-25'); + renderWeekListItemHeader(weekItem, {onDownArrowClick, isExpanded: false}); + await waitForBatchedUpdatesWithAct(); + + // The expand/collapse button should be rendered with "Expand" label when not expanded + const expandButton = screen.getByLabelText('Expand'); + expect(expandButton).toBeOnTheScreen(); + }); + + it('should call onDownArrowClick when expand/collapse button is pressed', async () => { + const onDownArrowClick = jest.fn(); + const weekItem = createWeekListItem('2026-01-25'); + renderWeekListItemHeader(weekItem, {onDownArrowClick, isExpanded: false}); + await waitForBatchedUpdatesWithAct(); + + const expandButton = screen.getByLabelText('Expand'); + fireEvent.press(expandButton); + + expect(onDownArrowClick).toHaveBeenCalled(); + }); + + it('should show "Collapse" label when isExpanded is true', async () => { + const onDownArrowClick = jest.fn(); + const weekItem = createWeekListItem('2026-01-25'); + renderWeekListItemHeader(weekItem, {onDownArrowClick, isExpanded: true}); + await waitForBatchedUpdatesWithAct(); + + const collapseButton = screen.getByLabelText('Collapse'); + expect(collapseButton).toBeOnTheScreen(); + }); + + it('should not render expand/collapse button when onDownArrowClick is not provided', async () => { + const weekItem = createWeekListItem('2026-01-25'); + renderWeekListItemHeader(weekItem); + await waitForBatchedUpdatesWithAct(); + + expect(screen.queryByLabelText('Expand')).not.toBeOnTheScreen(); + expect(screen.queryByLabelText('Collapse')).not.toBeOnTheScreen(); + }); + }); +}); From e1144cd2b2baa1c26807c898202abf79391ac556 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Tue, 27 Jan 2026 16:49:31 -0800 Subject: [PATCH 09/26] Tests --- tests/unit/Search/SearchUIUtilsTest.ts | 141 +++++++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index 193191d0c30b..5f7b4a04d498 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -15,6 +15,7 @@ import type { TransactionMonthGroupListItemType, TransactionReportGroupListItemType, TransactionTagGroupListItemType, + TransactionWeekGroupListItemType, TransactionWithdrawalIDGroupListItemType, } from '@components/SelectionListWithSections/types'; import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; @@ -1780,6 +1781,64 @@ const transactionTagGroupListItems: TransactionTagGroupListItemType[] = [ }, ]; +const searchResultsGroupByWeek: OnyxTypes.SearchResults = { + data: { + personalDetailsList: {}, + [`${CONST.SEARCH.GROUP_PREFIX}2026-01-25` as const]: { + week: '2026-01-25', + count: 5, + currency: 'USD', + total: 250, + }, + [`${CONST.SEARCH.GROUP_PREFIX}2025-12-28` as const]: { + week: '2025-12-28', + count: 3, + currency: 'USD', + total: 75, + }, + }, + search: { + count: 8, + currency: 'USD', + hasMoreResults: false, + hasResults: true, + offset: 0, + status: CONST.SEARCH.STATUS.EXPENSE.ALL, + total: 325, + isLoading: false, + type: 'expense', + }, +}; + +// Note: formattedWeek uses DateUtils.getFormattedDateRangeForSearch which returns a date range format +// For week starting 2026-01-25 (Sunday), it would format as "Jan 25 - Jan 31, 2026" (if same year) +// or "Jan 25, 2026 - Feb 1, 2026" (if different year) +// We'll use a placeholder that matches the actual format +const transactionWeekGroupListItems: TransactionWeekGroupListItemType[] = [ + { + week: '2026-01-25', + count: 5, + currency: 'USD', + total: 250, + groupedBy: CONST.SEARCH.GROUP_BY.WEEK, + formattedWeek: 'Jan 25 - Jan 31, 2026', + sortKey: '2026-01-25', + transactions: [], + transactionsQueryJSON: undefined, + }, + { + week: '2025-12-28', + count: 3, + currency: 'USD', + total: 75, + groupedBy: CONST.SEARCH.GROUP_BY.WEEK, + formattedWeek: 'Dec 28, 2025 - Jan 3, 2026', + sortKey: '2025-12-28', + transactions: [], + transactionsQueryJSON: undefined, + }, +]; + const searchResultsGroupByMonth: OnyxTypes.SearchResults = { data: { personalDetailsList: {}, @@ -2578,6 +2637,88 @@ describe('SearchUIUtils', () => { expect(SearchUIUtils.isTransactionMonthGroupListItemType(monthItem)).toBe(true); }); + it('should return isTransactionWeekGroupListItemType true for week group items', () => { + const weekItem: TransactionWeekGroupListItemType = { + week: '2026-01-25', + count: 5, + currency: 'USD', + total: 250, + groupedBy: CONST.SEARCH.GROUP_BY.WEEK, + formattedWeek: 'Week of January 25, 2026', + sortKey: '2026-01-25', + transactions: [], + transactionsQueryJSON: undefined, + }; + + expect(SearchUIUtils.isTransactionWeekGroupListItemType(weekItem)).toBe(true); + }); + + it('should return getWeekSections result when type is EXPENSE and groupBy is week', () => { + expect( + SearchUIUtils.getSections({ + type: CONST.SEARCH.DATA_TYPES.EXPENSE, + data: searchResultsGroupByWeek.data, + currentAccountID: 2074551, + currentUserEmail: '', + translate: translateLocal, + formatPhoneNumber, + bankAccountList: {}, + groupBy: CONST.SEARCH.GROUP_BY.WEEK, + })[0], + ).toStrictEqual(transactionWeekGroupListItems); + }); + + it('should format week dates correctly', () => { + const dataWithDifferentWeeks: OnyxTypes.SearchResults['data'] = { + personalDetailsList: {}, + [`${CONST.SEARCH.GROUP_PREFIX}2026-01-25` as const]: { + week: '2026-01-25', + count: 2, + currency: 'USD', + total: 50, + }, + [`${CONST.SEARCH.GROUP_PREFIX}2026-06-15` as const]: { + week: '2026-06-15', + count: 1, + currency: 'USD', + total: 25, + }, + }; + + const [result] = SearchUIUtils.getSections({ + type: CONST.SEARCH.DATA_TYPES.EXPENSE, + data: dataWithDifferentWeeks, + currentAccountID: 2074551, + currentUserEmail: '', + translate: translateLocal, + formatPhoneNumber, + bankAccountList: {}, + groupBy: CONST.SEARCH.GROUP_BY.WEEK, + }) as [TransactionWeekGroupListItemType[], number]; + + expect(result).toHaveLength(2); + // Check that formatted week contains the start date + expect(result.some((item) => item.formattedWeek.includes('Jan 25'))).toBe(true); + expect(result.some((item) => item.formattedWeek.includes('Jun 15'))).toBe(true); + }); + + it('should calculate sortKey correctly for week groups', () => { + const [result] = SearchUIUtils.getSections({ + type: CONST.SEARCH.DATA_TYPES.EXPENSE, + data: searchResultsGroupByWeek.data, + currentAccountID: 2074551, + currentUserEmail: '', + translate: translateLocal, + formatPhoneNumber, + bankAccountList: {}, + groupBy: CONST.SEARCH.GROUP_BY.WEEK, + }) as [TransactionWeekGroupListItemType[], number]; + + expect(result).toHaveLength(2); + expect(result.some((item) => item.sortKey === '2026-01-25')).toBe(true); + expect(result.some((item) => item.sortKey === '2025-12-28')).toBe(true); + }); + it('should return isTransactionCategoryGroupListItemType false for non-category group items', () => { const memberItem: TransactionMemberGroupListItemType = { accountID: 123, From 2a47570b1997f430982936ce54f6c42dee74fcb4 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Tue, 27 Jan 2026 16:49:42 -0800 Subject: [PATCH 10/26] Run prettier --- src/types/onyx/SearchResults.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/types/onyx/SearchResults.ts b/src/types/onyx/SearchResults.ts index df6fc321c3a7..f3854dbfd4e1 100644 --- a/src/types/onyx/SearchResults.ts +++ b/src/types/onyx/SearchResults.ts @@ -249,7 +249,10 @@ type SearchResults = { PrefixedRecord & PrefixedRecord & PrefixedRecord & - PrefixedRecord; + PrefixedRecord< + typeof CONST.SEARCH.GROUP_PREFIX, + SearchMemberGroup | SearchCardGroup | SearchWithdrawalIDGroup | SearchCategoryGroup | SearchTagGroup | SearchMonthGroup | SearchWeekGroup + >; /** Whether search data is being fetched from server */ isLoading?: boolean; From e4f03939870e01e8065fc372ee5b86272a29b10d Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Tue, 27 Jan 2026 17:03:24 -0800 Subject: [PATCH 11/26] Fix typecheck --- src/libs/SearchUIUtils.ts | 46 +++++---------------------------------- 1 file changed, 6 insertions(+), 40 deletions(-) diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 1e7fa38fa641..e6172bc7bf5a 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -3620,42 +3620,25 @@ function getColumnsToShow( return result; } - if (groupBy === CONST.SEARCH.GROUP_BY.WEEK) { - const requiredColumns = new Set([CONST.SEARCH.TABLE_COLUMNS.GROUP_WEEK]); - const result: SearchColumnType[] = []; - - for (const col of requiredColumns) { - if (!(columnsToShow as SearchColumnType[]).includes(col)) { - result.push(col); - } - } - - for (const col of columnsToShow ?? []) { - result.push(col); - } - - return result; - } - if (groupBy === CONST.SEARCH.GROUP_BY.TAG) { const requiredColumns = new Set([CONST.SEARCH.TABLE_COLUMNS.GROUP_TAG]); const result: SearchColumnType[] = []; for (const col of requiredColumns) { - if (!(columnsToShow as SearchColumnType[]).includes(col)) { + if (!columnsToShow.includes(col as SearchCustomColumnIds)) { result.push(col); } } - for (const col of columnsToShow ?? []) { + for (const col of columnsToShow) { result.push(col); } return result; } - if (groupBy === CONST.SEARCH.GROUP_BY.WEEK) { - const requiredColumns = new Set([CONST.SEARCH.TABLE_COLUMNS.GROUP_WEEK]); + if (groupBy === CONST.SEARCH.GROUP_BY.MONTH) { + const requiredColumns = new Set([CONST.SEARCH.TABLE_COLUMNS.GROUP_MONTH]); const result: SearchColumnType[] = []; for (const col of requiredColumns) { @@ -3671,25 +3654,8 @@ function getColumnsToShow( return result; } - if (groupBy === CONST.SEARCH.GROUP_BY.TAG) { - const requiredColumns = new Set([CONST.SEARCH.TABLE_COLUMNS.GROUP_TAG]); - const result: SearchColumnType[] = []; - - for (const col of requiredColumns) { - if (!columnsToShow.includes(col as SearchCustomColumnIds)) { - result.push(col); - } - } - - for (const col of columnsToShow) { - result.push(col); - } - - return result; - } - - if (groupBy === CONST.SEARCH.GROUP_BY.MONTH) { - const requiredColumns = new Set([CONST.SEARCH.TABLE_COLUMNS.GROUP_MONTH]); + if (groupBy === CONST.SEARCH.GROUP_BY.WEEK) { + const requiredColumns = new Set([CONST.SEARCH.TABLE_COLUMNS.GROUP_WEEK]); const result: SearchColumnType[] = []; for (const col of requiredColumns) { From 6c2b059b29db45cf4d1b84e3e9eb60f9aa1c913c Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Tue, 27 Jan 2026 17:06:38 -0800 Subject: [PATCH 12/26] Fix ESLisnt --- src/components/Search/index.tsx | 3 +- .../Search/WeekListItemHeader.tsx | 1 - src/libs/SearchUIUtils.ts | 32 +++++++++++++++---- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 0b62e32b25d6..bb8c678f7b82 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -15,7 +15,6 @@ import type { SelectionListHandle, TransactionGroupListItemType, TransactionListItemType, - TransactionWeekGroupListItemType, } from '@components/SelectionListWithSections/types'; import SearchRowSkeleton from '@components/Skeletons/SearchRowSkeleton'; import {WideRHPContext} from '@components/WideRHPContextProvider'; @@ -883,7 +882,7 @@ function Search({ } if (isTransactionWeekGroupListItemType(item)) { - const weekGroupItem = item as TransactionWeekGroupListItemType; + const weekGroupItem = item; if (!weekGroupItem.week) { return; } diff --git a/src/components/SelectionListWithSections/Search/WeekListItemHeader.tsx b/src/components/SelectionListWithSections/Search/WeekListItemHeader.tsx index 47e7e20d215c..d71725ead66a 100644 --- a/src/components/SelectionListWithSections/Search/WeekListItemHeader.tsx +++ b/src/components/SelectionListWithSections/Search/WeekListItemHeader.tsx @@ -8,7 +8,6 @@ import useLocalize from '@hooks/useLocalize'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; -import DateUtils from '@libs/DateUtils'; import CONST from '@src/CONST'; import ExpandCollapseArrowButton from './ExpandCollapseArrowButton'; import TextCell from './TextCell'; diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index e6172bc7bf5a..47b53d7b84d5 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -1,4 +1,4 @@ -import {addDays, endOfWeek, format} from 'date-fns'; +import {format} from 'date-fns'; import type {TextStyle, ViewStyle} from 'react-native'; import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; @@ -156,6 +156,7 @@ type TransactionWithdrawalIDGroupSorting = ColumnSortMapping; type TransactionTagGroupSorting = ColumnSortMapping; type TransactionMonthGroupSorting = ColumnSortMapping; +type TransactionWeekGroupSorting = ColumnSortMapping; type GetReportSectionsParams = { data: OnyxTypes.SearchResults['data']; @@ -264,6 +265,12 @@ const transactionMonthGroupColumnNamesToSortingProperty: TransactionMonthGroupSo [CONST.SEARCH.TABLE_COLUMNS.GROUP_TOTAL]: 'total' as const, }; +const transactionWeekGroupColumnNamesToSortingProperty: TransactionWeekGroupSorting = { + [CONST.SEARCH.TABLE_COLUMNS.GROUP_WEEK]: 'sortKey' as const, + [CONST.SEARCH.TABLE_COLUMNS.GROUP_EXPENSES]: 'count' as const, + [CONST.SEARCH.TABLE_COLUMNS.GROUP_TOTAL]: 'total' as const, +}; + const expenseStatusActionMapping = { [CONST.SEARCH.STATUS.EXPENSE.DRAFTS]: (expenseReport?: OnyxTypes.Report) => expenseReport?.stateNum === CONST.REPORT.STATE_NUM.OPEN && expenseReport.statusNum === CONST.REPORT.STATUS_NUM.OPEN, @@ -2494,6 +2501,8 @@ function getSortedSections( return getSortedTagData(data as TransactionTagGroupListItemType[], localeCompare, sortBy, sortOrder); case CONST.SEARCH.GROUP_BY.MONTH: return getSortedMonthData(data as TransactionMonthGroupListItemType[], localeCompare, sortBy, sortOrder); + case CONST.SEARCH.GROUP_BY.WEEK: + return getSortedWeekData(data as TransactionWeekGroupListItemType[], localeCompare, sortBy, sortOrder); } } @@ -2881,6 +2890,15 @@ function getSortedMonthData(data: TransactionMonthGroupListItemType[], localeCom return getSortedData(data, localeCompare, transactionMonthGroupColumnNamesToSortingProperty, (a, b) => a.sortKey - b.sortKey, sortBy, sortOrder); } +/** + * Sorts week group data based on a specified column and sort order. + */ +function getSortedWeekData(data: TransactionWeekGroupListItemType[], localeCompare: LocaleContextProps['localeCompare'], sortBy?: SearchColumnType, sortOrder?: SortOrder) { + // For week groups, sortKey is a string (date in YYYY-MM-DD format), so we compare strings + // Use localeCompare from context for consistent string comparison + return getSortedData(data, localeCompare, transactionWeekGroupColumnNamesToSortingProperty, (a, b) => localeCompare(b.sortKey, a.sortKey), sortBy, sortOrder); +} + /** * @private * Sorts report actions sections based on a specified column and sort order. @@ -3557,7 +3575,7 @@ function getColumnsToShow( const result: SearchColumnType[] = []; for (const col of requiredColumns) { - if (!(columnsToShow as SearchColumnType[]).includes(col)) { + if (!columnsToShow.includes(col)) { result.push(col); } } @@ -3574,7 +3592,7 @@ function getColumnsToShow( const result: SearchColumnType[] = []; for (const col of requiredColumns) { - if (!(columnsToShow as SearchColumnType[]).includes(col)) { + if (!columnsToShow.includes(col)) { result.push(col); } } @@ -3591,7 +3609,7 @@ function getColumnsToShow( const result: SearchColumnType[] = []; for (const col of requiredColumns) { - if (!(columnsToShow as SearchColumnType[]).includes(col)) { + if (!columnsToShow.includes(col)) { result.push(col); } } @@ -3608,7 +3626,7 @@ function getColumnsToShow( const result: SearchColumnType[] = []; for (const col of requiredColumns) { - if (!(columnsToShow as SearchColumnType[]).includes(col)) { + if (!columnsToShow.includes(col)) { result.push(col); } } @@ -3642,7 +3660,7 @@ function getColumnsToShow( const result: SearchColumnType[] = []; for (const col of requiredColumns) { - if (!(columnsToShow as SearchColumnType[]).includes(col)) { + if (!columnsToShow.includes(col)) { result.push(col); } } @@ -3659,7 +3677,7 @@ function getColumnsToShow( const result: SearchColumnType[] = []; for (const col of requiredColumns) { - if (!(columnsToShow as SearchColumnType[]).includes(col)) { + if (!columnsToShow.includes(col)) { result.push(col); } } From 707ac24f561ed3142bbf74589be9d1a9178fb97b Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Tue, 27 Jan 2026 17:07:27 -0800 Subject: [PATCH 13/26] prettier --- src/components/Search/index.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index bb8c678f7b82..5f9323be6f93 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -9,13 +9,7 @@ import FullPageErrorView from '@components/BlockingViews/FullPageErrorView'; import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView'; import {ModalActions} from '@components/Modal/Global/ModalContext'; import SearchTableHeader from '@components/SelectionListWithSections/SearchTableHeader'; -import type { - ReportActionListItemType, - SearchListItem, - SelectionListHandle, - TransactionGroupListItemType, - TransactionListItemType, -} from '@components/SelectionListWithSections/types'; +import type {ReportActionListItemType, SearchListItem, SelectionListHandle, TransactionGroupListItemType, TransactionListItemType} from '@components/SelectionListWithSections/types'; import SearchRowSkeleton from '@components/Skeletons/SearchRowSkeleton'; import {WideRHPContext} from '@components/WideRHPContextProvider'; import useArchivedReportsIdSet from '@hooks/useArchivedReportsIdSet'; From 68ad91affbeed0fa9b0b2f8728621ec36837c537 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Tue, 27 Jan 2026 17:31:50 -0800 Subject: [PATCH 14/26] FIx sorting --- .../SelectionListWithSections/types.ts | 3 - src/libs/SearchParser/autocompleteParser.js | 291 +++++++++-------- src/libs/SearchParser/baseRules.peggy | 2 + src/libs/SearchParser/searchParser.js | 295 ++++++++++-------- src/libs/SearchParser/searchParser.peggy | 4 +- src/libs/SearchUIUtils.ts | 6 +- 6 files changed, 344 insertions(+), 257 deletions(-) diff --git a/src/components/SelectionListWithSections/types.ts b/src/components/SelectionListWithSections/types.ts index 8204f392a8ce..f4f8c5e3ac44 100644 --- a/src/components/SelectionListWithSections/types.ts +++ b/src/components/SelectionListWithSections/types.ts @@ -521,9 +521,6 @@ type TransactionTagGroupListItemType = TransactionGroupListItemType & {groupedBy type TransactionWeekGroupListItemType = TransactionGroupListItemType & {groupedBy: typeof CONST.SEARCH.GROUP_BY.WEEK} & SearchWeekGroup & { /** Final and formatted "week" value used for displaying */ formattedWeek: string; - - /** Key used for sorting */ - sortKey: string; }; type ListItemProps = CommonListItemProps & { diff --git a/src/libs/SearchParser/autocompleteParser.js b/src/libs/SearchParser/autocompleteParser.js index 95b3aea65ccd..56ae68904f54 100644 --- a/src/libs/SearchParser/autocompleteParser.js +++ b/src/libs/SearchParser/autocompleteParser.js @@ -271,14 +271,15 @@ function peg$parse(input, options) { var peg$c85 = "group-withdrawal-id"; var peg$c86 = "group-category"; var peg$c87 = "group-month"; - var peg$c88 = "!="; - var peg$c89 = ">="; - var peg$c90 = ">"; - var peg$c91 = "<="; - var peg$c92 = "<"; - var peg$c93 = "\u201C"; - var peg$c94 = "\u201D"; - var peg$c95 = "\""; + var peg$c88 = "group-week"; + var peg$c89 = "!="; + var peg$c90 = ">="; + var peg$c91 = ">"; + var peg$c92 = "<="; + var peg$c93 = "<"; + var peg$c94 = "\u201C"; + var peg$c95 = "\u201D"; + var peg$c96 = "\""; var peg$r0 = /^[ \t\r\n\xA0,:=<>!]/; var peg$r1 = /^[:=]/; @@ -385,30 +386,31 @@ function peg$parse(input, options) { var peg$e88 = peg$literalExpectation("group-withdrawal-id", true); var peg$e89 = peg$literalExpectation("group-category", true); var peg$e90 = peg$literalExpectation("group-month", true); - var peg$e91 = peg$otherExpectation("operator"); - var peg$e92 = peg$classExpectation([":", "="], false, false); - var peg$e93 = peg$literalExpectation("!=", false); - var peg$e94 = peg$literalExpectation(">=", false); - var peg$e95 = peg$literalExpectation(">", false); - var peg$e96 = peg$literalExpectation("<=", false); - var peg$e97 = peg$literalExpectation("<", false); - var peg$e98 = peg$otherExpectation("word"); - var peg$e99 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e100 = peg$otherExpectation("whitespace"); - var peg$e101 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); - var peg$e102 = peg$otherExpectation("quote"); - var peg$e103 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e104 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); - var peg$e105 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); - var peg$e106 = peg$literalExpectation("\u201C", false); - var peg$e107 = peg$literalExpectation("\u201D", false); - var peg$e108 = peg$literalExpectation("\"", false); - var peg$e109 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e110 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e111 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); - var peg$e112 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); - var peg$e113 = peg$classExpectation([","], false, false); - var peg$e114 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); + var peg$e91 = peg$literalExpectation("group-week", true); + var peg$e92 = peg$otherExpectation("operator"); + var peg$e93 = peg$classExpectation([":", "="], false, false); + var peg$e94 = peg$literalExpectation("!=", false); + var peg$e95 = peg$literalExpectation(">=", false); + var peg$e96 = peg$literalExpectation(">", false); + var peg$e97 = peg$literalExpectation("<=", false); + var peg$e98 = peg$literalExpectation("<", false); + var peg$e99 = peg$otherExpectation("word"); + var peg$e100 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e101 = peg$otherExpectation("whitespace"); + var peg$e102 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); + var peg$e103 = peg$otherExpectation("quote"); + var peg$e104 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e105 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); + var peg$e106 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); + var peg$e107 = peg$literalExpectation("\u201C", false); + var peg$e108 = peg$literalExpectation("\u201D", false); + var peg$e109 = peg$literalExpectation("\"", false); + var peg$e110 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e111 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e112 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); + var peg$e113 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); + var peg$e114 = peg$classExpectation([","], false, false); + var peg$e115 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); var peg$f0 = function(ranges) { return { autocomplete, ranges }; }; var peg$f1 = function(filters) { return filters.filter(Boolean).flat(); }; @@ -548,32 +550,33 @@ function peg$parse(input, options) { var peg$f77 = function() { return "groupWithdrawalID"; }; var peg$f78 = function() { return "groupCategory"; }; var peg$f79 = function() { return "groupMonth"; }; - var peg$f80 = function() { return "eq"; }; - var peg$f81 = function() { return "neq"; }; - var peg$f82 = function() { return "gte"; }; - var peg$f83 = function() { return "gt"; }; - var peg$f84 = function() { return "lte"; }; - var peg$f85 = function() { return "lt"; }; - var peg$f86 = function(o) { + var peg$f80 = function() { return "groupWeek"; }; + var peg$f81 = function() { return "eq"; }; + var peg$f82 = function() { return "neq"; }; + var peg$f83 = function() { return "gte"; }; + var peg$f84 = function() { return "gt"; }; + var peg$f85 = function() { return "lte"; }; + var peg$f86 = function() { return "lt"; }; + var peg$f87 = function(o) { if (nameOperator) { expectingNestedQuote = (o === "eq"); // Use simple parser if no valid operator is found } isColumnsContext = false; return o; }; - var peg$f87 = function(chars) { return chars.join("").trim(); }; - var peg$f88 = function() { + var peg$f88 = function(chars) { return chars.join("").trim(); }; + var peg$f89 = function() { isColumnsContext = false; return "and"; }; - var peg$f89 = function() { return expectingNestedQuote; }; - var peg$f90 = function(start, inner, end) { //handle no-breaking space + var peg$f90 = function() { return expectingNestedQuote; }; + var peg$f91 = function(start, inner, end) { //handle no-breaking space return [...start, '"', ...inner, '"', ...end].join(""); }; - var peg$f91 = function(start) {return "“"}; - var peg$f92 = function(start) {return "”"}; - var peg$f93 = function(start) {return "\""}; - var peg$f94 = function(start, inner, end) { + var peg$f92 = function(start) {return "“"}; + var peg$f93 = function(start) {return "”"}; + var peg$f94 = function(start) {return "\""}; + var peg$f95 = function(start, inner, end) { return [...start, '"', ...inner, '"'].join(""); }; var peg$currPos = options.peg$currPos | 0; @@ -2376,6 +2379,9 @@ function peg$parse(input, options) { s0 = peg$parsegroupCategory(); if (s0 === peg$FAILED) { s0 = peg$parsegroupMonth(); + if (s0 === peg$FAILED) { + s0 = peg$parsegroupWeek(); + } } } } @@ -3298,6 +3304,43 @@ function peg$parse(input, options) { return s0; } + function peg$parsegroupWeek() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 10); + if (s1.toLowerCase() === peg$c88) { + peg$currPos += 10; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e91); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parsewordBoundary(); + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = undefined; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f80(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + function peg$parseoperator() { var s0, s1; @@ -3308,81 +3351,81 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e92); } + if (peg$silentFails === 0) { peg$fail(peg$e93); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f80(); + s1 = peg$f81(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c88) { - s1 = peg$c88; + if (input.substr(peg$currPos, 2) === peg$c89) { + s1 = peg$c89; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e93); } + if (peg$silentFails === 0) { peg$fail(peg$e94); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f81(); + s1 = peg$f82(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c89) { - s1 = peg$c89; + if (input.substr(peg$currPos, 2) === peg$c90) { + s1 = peg$c90; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e94); } + if (peg$silentFails === 0) { peg$fail(peg$e95); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f82(); + s1 = peg$f83(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 62) { - s1 = peg$c90; + s1 = peg$c91; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e95); } + if (peg$silentFails === 0) { peg$fail(peg$e96); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f83(); + s1 = peg$f84(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c91) { - s1 = peg$c91; + if (input.substr(peg$currPos, 2) === peg$c92) { + s1 = peg$c92; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e96); } + if (peg$silentFails === 0) { peg$fail(peg$e97); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f84(); + s1 = peg$f85(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 60) { - s1 = peg$c92; + s1 = peg$c93; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e97); } + if (peg$silentFails === 0) { peg$fail(peg$e98); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f85(); + s1 = peg$f86(); } s0 = s1; } @@ -3393,7 +3436,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e91); } + if (peg$silentFails === 0) { peg$fail(peg$e92); } } return s0; @@ -3406,7 +3449,7 @@ function peg$parse(input, options) { s1 = peg$parseoperator(); if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f86(s1); + s1 = peg$f87(s1); } s0 = s1; @@ -3424,7 +3467,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e99); } + if (peg$silentFails === 0) { peg$fail(peg$e100); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { @@ -3434,7 +3477,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e99); } + if (peg$silentFails === 0) { peg$fail(peg$e100); } } } } else { @@ -3442,13 +3485,13 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f87(s1); + s1 = peg$f88(s1); } s0 = s1; peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e98); } + if (peg$silentFails === 0) { peg$fail(peg$e99); } } return s0; @@ -3460,7 +3503,7 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parse_(); peg$savedPos = s0; - s1 = peg$f88(); + s1 = peg$f89(); s0 = s1; return s0; @@ -3476,7 +3519,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e101); } + if (peg$silentFails === 0) { peg$fail(peg$e102); } } while (s1 !== peg$FAILED) { s0.push(s1); @@ -3485,12 +3528,12 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e101); } + if (peg$silentFails === 0) { peg$fail(peg$e102); } } } peg$silentFails--; s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e100); } + if (peg$silentFails === 0) { peg$fail(peg$e101); } return s0; } @@ -3500,7 +3543,7 @@ function peg$parse(input, options) { s0 = peg$currPos; peg$savedPos = peg$currPos; - s1 = peg$f89(); + s1 = peg$f90(); if (s1) { s1 = undefined; } else { @@ -3537,7 +3580,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } + if (peg$silentFails === 0) { peg$fail(peg$e104); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -3546,7 +3589,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } + if (peg$silentFails === 0) { peg$fail(peg$e104); } } } s2 = input.charAt(peg$currPos); @@ -3554,7 +3597,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } + if (peg$silentFails === 0) { peg$fail(peg$e105); } } if (s2 !== peg$FAILED) { s3 = []; @@ -3563,7 +3606,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -3572,7 +3615,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } } s4 = input.charAt(peg$currPos); @@ -3580,7 +3623,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } + if (peg$silentFails === 0) { peg$fail(peg$e105); } } if (s4 !== peg$FAILED) { s5 = []; @@ -3589,7 +3632,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e99); } + if (peg$silentFails === 0) { peg$fail(peg$e100); } } while (s6 !== peg$FAILED) { s5.push(s6); @@ -3598,11 +3641,11 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e99); } + if (peg$silentFails === 0) { peg$fail(peg$e100); } } } peg$savedPos = s0; - s0 = peg$f90(s1, s3, s5); + s0 = peg$f91(s1, s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3614,7 +3657,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e102); } + if (peg$silentFails === 0) { peg$fail(peg$e103); } } return s0; @@ -3631,7 +3674,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } + if (peg$silentFails === 0) { peg$fail(peg$e104); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -3640,7 +3683,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } + if (peg$silentFails === 0) { peg$fail(peg$e104); } } } s2 = input.charAt(peg$currPos); @@ -3648,7 +3691,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } + if (peg$silentFails === 0) { peg$fail(peg$e105); } } if (s2 !== peg$FAILED) { s3 = []; @@ -3657,7 +3700,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -3673,15 +3716,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c93; + s6 = peg$c94; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f91(s1); + s4 = peg$f92(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3704,15 +3747,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c94; + s6 = peg$c95; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f92(s1); + s4 = peg$f93(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3735,15 +3778,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c95; + s6 = peg$c96; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { peg$fail(peg$e109); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f93(s1); + s4 = peg$f94(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3762,7 +3805,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -3778,15 +3821,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c93; + s6 = peg$c94; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f91(s1); + s4 = peg$f92(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3809,15 +3852,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c94; + s6 = peg$c95; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f92(s1); + s4 = peg$f93(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3840,15 +3883,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c95; + s6 = peg$c96; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { peg$fail(peg$e109); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f93(s1); + s4 = peg$f94(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3864,7 +3907,7 @@ function peg$parse(input, options) { s4 = peg$parseclosingQuote(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f94(s1, s3, s4); + s0 = peg$f95(s1, s3, s4); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3876,7 +3919,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e102); } + if (peg$silentFails === 0) { peg$fail(peg$e103); } } return s0; @@ -3891,7 +3934,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } + if (peg$silentFails === 0) { peg$fail(peg$e105); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3929,7 +3972,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e109); } + if (peg$silentFails === 0) { peg$fail(peg$e110); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -3938,7 +3981,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e109); } + if (peg$silentFails === 0) { peg$fail(peg$e110); } } } s2 = []; @@ -3947,7 +3990,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e110); } + if (peg$silentFails === 0) { peg$fail(peg$e111); } } while (s3 !== peg$FAILED) { s2.push(s3); @@ -3956,7 +3999,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e110); } + if (peg$silentFails === 0) { peg$fail(peg$e111); } } } s3 = []; @@ -3965,7 +4008,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e111); } + if (peg$silentFails === 0) { peg$fail(peg$e112); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -3974,7 +4017,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e111); } + if (peg$silentFails === 0) { peg$fail(peg$e112); } } } s4 = peg$parseoperator(); @@ -3993,7 +4036,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e112); } + if (peg$silentFails === 0) { peg$fail(peg$e113); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -4002,7 +4045,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e112); } + if (peg$silentFails === 0) { peg$fail(peg$e113); } } } s2 = peg$currPos; @@ -4049,7 +4092,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e113); } + if (peg$silentFails === 0) { peg$fail(peg$e114); } } } } @@ -4065,7 +4108,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e114); } + if (peg$silentFails === 0) { peg$fail(peg$e115); } } if (s0 === peg$FAILED) { s0 = peg$currPos; diff --git a/src/libs/SearchParser/baseRules.peggy b/src/libs/SearchParser/baseRules.peggy index 1a8c6d48e905..7da49c4c9e77 100644 --- a/src/libs/SearchParser/baseRules.peggy +++ b/src/libs/SearchParser/baseRules.peggy @@ -115,6 +115,7 @@ columnsValues / groupWithdrawalId / groupCategory / groupMonth + / groupWeek perDiem = "per-diem"i &wordBoundary { return "perDiem"; } draft = ("drafts"i / "draft"i) &wordBoundary { return "drafts"; } @@ -140,6 +141,7 @@ groupWithdrawn = "group-withdrawn"i &wordBoundary { return "gr groupWithdrawalId = "group-withdrawal-id"i &wordBoundary { return "groupWithdrawalID"; } groupCategory = "group-category"i &wordBoundary { return "groupCategory"; } groupMonth = "group-month"i &wordBoundary { return "groupMonth"; } +groupWeek = "group-week"i &wordBoundary { return "groupWeek"; } operator "operator" diff --git a/src/libs/SearchParser/searchParser.js b/src/libs/SearchParser/searchParser.js index dd66d002472e..71b9d733685d 100644 --- a/src/libs/SearchParser/searchParser.js +++ b/src/libs/SearchParser/searchParser.js @@ -272,14 +272,15 @@ function peg$parse(input, options) { var peg$c85 = "group-withdrawal-id"; var peg$c86 = "group-category"; var peg$c87 = "group-month"; - var peg$c88 = "!="; - var peg$c89 = ">="; - var peg$c90 = ">"; - var peg$c91 = "<="; - var peg$c92 = "<"; - var peg$c93 = "\u201C"; - var peg$c94 = "\u201D"; - var peg$c95 = "\""; + var peg$c88 = "group-week"; + var peg$c89 = "!="; + var peg$c90 = ">="; + var peg$c91 = ">"; + var peg$c92 = "<="; + var peg$c93 = "<"; + var peg$c94 = "\u201C"; + var peg$c95 = "\u201D"; + var peg$c96 = "\""; var peg$r0 = /^[^ \t\r\n\xA0]/; var peg$r1 = /^[ \t\r\n\xA0,:=<>!]/; @@ -389,30 +390,31 @@ function peg$parse(input, options) { var peg$e90 = peg$literalExpectation("group-withdrawal-id", true); var peg$e91 = peg$literalExpectation("group-category", true); var peg$e92 = peg$literalExpectation("group-month", true); - var peg$e93 = peg$otherExpectation("operator"); - var peg$e94 = peg$classExpectation([":", "="], false, false); - var peg$e95 = peg$literalExpectation("!=", false); - var peg$e96 = peg$literalExpectation(">=", false); - var peg$e97 = peg$literalExpectation(">", false); - var peg$e98 = peg$literalExpectation("<=", false); - var peg$e99 = peg$literalExpectation("<", false); - var peg$e100 = peg$otherExpectation("word"); - var peg$e101 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e102 = peg$otherExpectation("whitespace"); - var peg$e103 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); - var peg$e104 = peg$otherExpectation("quote"); - var peg$e105 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e106 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); - var peg$e107 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); - var peg$e108 = peg$literalExpectation("\u201C", false); - var peg$e109 = peg$literalExpectation("\u201D", false); - var peg$e110 = peg$literalExpectation("\"", false); - var peg$e111 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e112 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e113 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); - var peg$e114 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); - var peg$e115 = peg$classExpectation([","], false, false); - var peg$e116 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); + var peg$e93 = peg$literalExpectation("group-week", true); + var peg$e94 = peg$otherExpectation("operator"); + var peg$e95 = peg$classExpectation([":", "="], false, false); + var peg$e96 = peg$literalExpectation("!=", false); + var peg$e97 = peg$literalExpectation(">=", false); + var peg$e98 = peg$literalExpectation(">", false); + var peg$e99 = peg$literalExpectation("<=", false); + var peg$e100 = peg$literalExpectation("<", false); + var peg$e101 = peg$otherExpectation("word"); + var peg$e102 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e103 = peg$otherExpectation("whitespace"); + var peg$e104 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); + var peg$e105 = peg$otherExpectation("quote"); + var peg$e106 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e107 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); + var peg$e108 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); + var peg$e109 = peg$literalExpectation("\u201C", false); + var peg$e110 = peg$literalExpectation("\u201D", false); + var peg$e111 = peg$literalExpectation("\"", false); + var peg$e112 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e113 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e114 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); + var peg$e115 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); + var peg$e116 = peg$classExpectation([","], false, false); + var peg$e117 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); var peg$f0 = function(filters) { return applyDefaults(filters); }; var peg$f1 = function(head, tail) { @@ -575,32 +577,33 @@ function peg$parse(input, options) { var peg$f78 = function() { return "groupWithdrawalID"; }; var peg$f79 = function() { return "groupCategory"; }; var peg$f80 = function() { return "groupMonth"; }; - var peg$f81 = function() { return "eq"; }; - var peg$f82 = function() { return "neq"; }; - var peg$f83 = function() { return "gte"; }; - var peg$f84 = function() { return "gt"; }; - var peg$f85 = function() { return "lte"; }; - var peg$f86 = function() { return "lt"; }; - var peg$f87 = function(o) { + var peg$f81 = function() { return "groupWeek"; }; + var peg$f82 = function() { return "eq"; }; + var peg$f83 = function() { return "neq"; }; + var peg$f84 = function() { return "gte"; }; + var peg$f85 = function() { return "gt"; }; + var peg$f86 = function() { return "lte"; }; + var peg$f87 = function() { return "lt"; }; + var peg$f88 = function(o) { if (nameOperator) { expectingNestedQuote = (o === "eq"); // Use simple parser if no valid operator is found } isColumnsContext = false; return o; }; - var peg$f88 = function(chars) { return chars.join("").trim(); }; - var peg$f89 = function() { + var peg$f89 = function(chars) { return chars.join("").trim(); }; + var peg$f90 = function() { isColumnsContext = false; return "and"; }; - var peg$f90 = function() { return expectingNestedQuote; }; - var peg$f91 = function(start, inner, end) { //handle no-breaking space + var peg$f91 = function() { return expectingNestedQuote; }; + var peg$f92 = function(start, inner, end) { //handle no-breaking space return [...start, '"', ...inner, '"', ...end].join(""); }; - var peg$f92 = function(start) {return "“"}; - var peg$f93 = function(start) {return "”"}; - var peg$f94 = function(start) {return "\""}; - var peg$f95 = function(start, inner, end) { + var peg$f93 = function(start) {return "“"}; + var peg$f94 = function(start) {return "”"}; + var peg$f95 = function(start) {return "\""}; + var peg$f96 = function(start, inner, end) { return [...start, '"', ...inner, '"'].join(""); }; var peg$currPos = options.peg$currPos | 0; @@ -2563,6 +2566,9 @@ function peg$parse(input, options) { s0 = peg$parsegroupCategory(); if (s0 === peg$FAILED) { s0 = peg$parsegroupMonth(); + if (s0 === peg$FAILED) { + s0 = peg$parsegroupWeek(); + } } } } @@ -3485,6 +3491,43 @@ function peg$parse(input, options) { return s0; } + function peg$parsegroupWeek() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 10); + if (s1.toLowerCase() === peg$c88) { + peg$currPos += 10; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e93); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parsewordBoundary(); + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = undefined; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f81(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + function peg$parseoperator() { var s0, s1; @@ -3495,81 +3538,81 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e94); } + if (peg$silentFails === 0) { peg$fail(peg$e95); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f81(); + s1 = peg$f82(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c88) { - s1 = peg$c88; + if (input.substr(peg$currPos, 2) === peg$c89) { + s1 = peg$c89; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e95); } + if (peg$silentFails === 0) { peg$fail(peg$e96); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f82(); + s1 = peg$f83(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c89) { - s1 = peg$c89; + if (input.substr(peg$currPos, 2) === peg$c90) { + s1 = peg$c90; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e96); } + if (peg$silentFails === 0) { peg$fail(peg$e97); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f83(); + s1 = peg$f84(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 62) { - s1 = peg$c90; + s1 = peg$c91; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e97); } + if (peg$silentFails === 0) { peg$fail(peg$e98); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f84(); + s1 = peg$f85(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c91) { - s1 = peg$c91; + if (input.substr(peg$currPos, 2) === peg$c92) { + s1 = peg$c92; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e98); } + if (peg$silentFails === 0) { peg$fail(peg$e99); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f85(); + s1 = peg$f86(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 60) { - s1 = peg$c92; + s1 = peg$c93; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e99); } + if (peg$silentFails === 0) { peg$fail(peg$e100); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f86(); + s1 = peg$f87(); } s0 = s1; } @@ -3580,7 +3623,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e93); } + if (peg$silentFails === 0) { peg$fail(peg$e94); } } return s0; @@ -3593,7 +3636,7 @@ function peg$parse(input, options) { s1 = peg$parseoperator(); if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f87(s1); + s1 = peg$f88(s1); } s0 = s1; @@ -3611,7 +3654,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e101); } + if (peg$silentFails === 0) { peg$fail(peg$e102); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { @@ -3621,7 +3664,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e101); } + if (peg$silentFails === 0) { peg$fail(peg$e102); } } } } else { @@ -3629,13 +3672,13 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f88(s1); + s1 = peg$f89(s1); } s0 = s1; peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e100); } + if (peg$silentFails === 0) { peg$fail(peg$e101); } } return s0; @@ -3647,7 +3690,7 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parse_(); peg$savedPos = s0; - s1 = peg$f89(); + s1 = peg$f90(); s0 = s1; return s0; @@ -3663,7 +3706,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } + if (peg$silentFails === 0) { peg$fail(peg$e104); } } while (s1 !== peg$FAILED) { s0.push(s1); @@ -3672,12 +3715,12 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } + if (peg$silentFails === 0) { peg$fail(peg$e104); } } } peg$silentFails--; s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e102); } + if (peg$silentFails === 0) { peg$fail(peg$e103); } return s0; } @@ -3687,7 +3730,7 @@ function peg$parse(input, options) { s0 = peg$currPos; peg$savedPos = peg$currPos; - s1 = peg$f90(); + s1 = peg$f91(); if (s1) { s1 = undefined; } else { @@ -3724,7 +3767,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -3733,7 +3776,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } } s2 = input.charAt(peg$currPos); @@ -3741,7 +3784,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } if (s2 !== peg$FAILED) { s3 = []; @@ -3750,7 +3793,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -3759,7 +3802,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } } s4 = input.charAt(peg$currPos); @@ -3767,7 +3810,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } if (s4 !== peg$FAILED) { s5 = []; @@ -3776,7 +3819,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e101); } + if (peg$silentFails === 0) { peg$fail(peg$e102); } } while (s6 !== peg$FAILED) { s5.push(s6); @@ -3785,11 +3828,11 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e101); } + if (peg$silentFails === 0) { peg$fail(peg$e102); } } } peg$savedPos = s0; - s0 = peg$f91(s1, s3, s5); + s0 = peg$f92(s1, s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3801,7 +3844,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } + if (peg$silentFails === 0) { peg$fail(peg$e105); } } return s0; @@ -3818,7 +3861,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -3827,7 +3870,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } } s2 = input.charAt(peg$currPos); @@ -3835,7 +3878,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } if (s2 !== peg$FAILED) { s3 = []; @@ -3844,7 +3887,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -3860,15 +3903,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c93; + s6 = peg$c94; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { peg$fail(peg$e109); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f92(s1); + s4 = peg$f93(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3891,15 +3934,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c94; + s6 = peg$c95; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e109); } + if (peg$silentFails === 0) { peg$fail(peg$e110); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f93(s1); + s4 = peg$f94(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3922,15 +3965,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c95; + s6 = peg$c96; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e110); } + if (peg$silentFails === 0) { peg$fail(peg$e111); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f94(s1); + s4 = peg$f95(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3949,7 +3992,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -3965,15 +4008,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c93; + s6 = peg$c94; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { peg$fail(peg$e109); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f92(s1); + s4 = peg$f93(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3996,15 +4039,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c94; + s6 = peg$c95; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e109); } + if (peg$silentFails === 0) { peg$fail(peg$e110); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f93(s1); + s4 = peg$f94(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4027,15 +4070,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c95; + s6 = peg$c96; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e110); } + if (peg$silentFails === 0) { peg$fail(peg$e111); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f94(s1); + s4 = peg$f95(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4051,7 +4094,7 @@ function peg$parse(input, options) { s4 = peg$parseclosingQuote(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f95(s1, s3, s4); + s0 = peg$f96(s1, s3, s4); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4063,7 +4106,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } + if (peg$silentFails === 0) { peg$fail(peg$e105); } } return s0; @@ -4078,7 +4121,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4116,7 +4159,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e111); } + if (peg$silentFails === 0) { peg$fail(peg$e112); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -4125,7 +4168,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e111); } + if (peg$silentFails === 0) { peg$fail(peg$e112); } } } s2 = []; @@ -4134,7 +4177,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e112); } + if (peg$silentFails === 0) { peg$fail(peg$e113); } } while (s3 !== peg$FAILED) { s2.push(s3); @@ -4143,7 +4186,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e112); } + if (peg$silentFails === 0) { peg$fail(peg$e113); } } } s3 = []; @@ -4152,7 +4195,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e113); } + if (peg$silentFails === 0) { peg$fail(peg$e114); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -4161,7 +4204,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e113); } + if (peg$silentFails === 0) { peg$fail(peg$e114); } } } s4 = peg$parseoperator(); @@ -4180,7 +4223,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e114); } + if (peg$silentFails === 0) { peg$fail(peg$e115); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -4189,7 +4232,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e114); } + if (peg$silentFails === 0) { peg$fail(peg$e115); } } } s2 = peg$currPos; @@ -4236,7 +4279,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e115); } + if (peg$silentFails === 0) { peg$fail(peg$e116); } } } } @@ -4252,7 +4295,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e116); } + if (peg$silentFails === 0) { peg$fail(peg$e117); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -4283,6 +4326,7 @@ function peg$parse(input, options) { "withdrawal-id": "withdrawn", category: "category", month: "groupmonth", + week: "groupweek", }; const GROUP_BY_DEFAULT_SORT_ORDER = { @@ -4290,7 +4334,8 @@ function peg$parse(input, options) { card: "asc", "withdrawal-id": "desc", category: "asc", - month: "desc" + month: "desc", + week: "desc", }; const DEFAULT_SORT_BY_VALUES = new Set([...Object.values(GROUP_BY_DEFAULT_SORT), "date"]); diff --git a/src/libs/SearchParser/searchParser.peggy b/src/libs/SearchParser/searchParser.peggy index 9dc46092f4cf..3e7e0dc6f386 100644 --- a/src/libs/SearchParser/searchParser.peggy +++ b/src/libs/SearchParser/searchParser.peggy @@ -34,6 +34,7 @@ "withdrawal-id": "withdrawn", category: "category", month: "groupmonth", + week: "groupweek", }; const GROUP_BY_DEFAULT_SORT_ORDER = { @@ -41,7 +42,8 @@ card: "asc", "withdrawal-id": "desc", category: "asc", - month: "desc" + month: "desc", + week: "desc", }; const DEFAULT_SORT_BY_VALUES = new Set([...Object.values(GROUP_BY_DEFAULT_SORT), "date"]); diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 47b53d7b84d5..1e4092681443 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -266,7 +266,7 @@ const transactionMonthGroupColumnNamesToSortingProperty: TransactionMonthGroupSo }; const transactionWeekGroupColumnNamesToSortingProperty: TransactionWeekGroupSorting = { - [CONST.SEARCH.TABLE_COLUMNS.GROUP_WEEK]: 'sortKey' as const, + [CONST.SEARCH.TABLE_COLUMNS.GROUP_WEEK]: 'week' as const, [CONST.SEARCH.TABLE_COLUMNS.GROUP_EXPENSES]: 'count' as const, [CONST.SEARCH.TABLE_COLUMNS.GROUP_TOTAL]: 'total' as const, }; @@ -2894,9 +2894,7 @@ function getSortedMonthData(data: TransactionMonthGroupListItemType[], localeCom * Sorts week group data based on a specified column and sort order. */ function getSortedWeekData(data: TransactionWeekGroupListItemType[], localeCompare: LocaleContextProps['localeCompare'], sortBy?: SearchColumnType, sortOrder?: SortOrder) { - // For week groups, sortKey is a string (date in YYYY-MM-DD format), so we compare strings - // Use localeCompare from context for consistent string comparison - return getSortedData(data, localeCompare, transactionWeekGroupColumnNamesToSortingProperty, (a, b) => localeCompare(b.sortKey, a.sortKey), sortBy, sortOrder); + return getSortedData(data, localeCompare, transactionWeekGroupColumnNamesToSortingProperty, (a, b) => localeCompare(a.week, b.week), sortBy, sortOrder); } /** From 4cd88b05c43e19e095a49f06d95219dac1642ff7 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Wed, 28 Jan 2026 06:22:15 -0800 Subject: [PATCH 15/26] Regenerate after resolving conflicts --- src/libs/SearchParser/autocompleteParser.js | 291 ++++++++++--------- src/libs/SearchParser/searchParser.js | 294 +++++++++++--------- 2 files changed, 336 insertions(+), 249 deletions(-) diff --git a/src/libs/SearchParser/autocompleteParser.js b/src/libs/SearchParser/autocompleteParser.js index 6155382cf255..c5c26ecb755b 100644 --- a/src/libs/SearchParser/autocompleteParser.js +++ b/src/libs/SearchParser/autocompleteParser.js @@ -272,14 +272,15 @@ function peg$parse(input, options) { var peg$c86 = "group-category"; var peg$c87 = "group-merchant"; var peg$c88 = "group-month"; - var peg$c89 = "!="; - var peg$c90 = ">="; - var peg$c91 = ">"; - var peg$c92 = "<="; - var peg$c93 = "<"; - var peg$c94 = "\u201C"; - var peg$c95 = "\u201D"; - var peg$c96 = "\""; + var peg$c89 = "group-week"; + var peg$c90 = "!="; + var peg$c91 = ">="; + var peg$c92 = ">"; + var peg$c93 = "<="; + var peg$c94 = "<"; + var peg$c95 = "\u201C"; + var peg$c96 = "\u201D"; + var peg$c97 = "\""; var peg$r0 = /^[ \t\r\n\xA0,:=<>!]/; var peg$r1 = /^[:=]/; @@ -387,30 +388,31 @@ function peg$parse(input, options) { var peg$e89 = peg$literalExpectation("group-category", true); var peg$e90 = peg$literalExpectation("group-merchant", true); var peg$e91 = peg$literalExpectation("group-month", true); - var peg$e92 = peg$otherExpectation("operator"); - var peg$e93 = peg$classExpectation([":", "="], false, false); - var peg$e94 = peg$literalExpectation("!=", false); - var peg$e95 = peg$literalExpectation(">=", false); - var peg$e96 = peg$literalExpectation(">", false); - var peg$e97 = peg$literalExpectation("<=", false); - var peg$e98 = peg$literalExpectation("<", false); - var peg$e99 = peg$otherExpectation("word"); - var peg$e100 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e101 = peg$otherExpectation("whitespace"); - var peg$e102 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); - var peg$e103 = peg$otherExpectation("quote"); - var peg$e104 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e105 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); - var peg$e106 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); - var peg$e107 = peg$literalExpectation("\u201C", false); - var peg$e108 = peg$literalExpectation("\u201D", false); - var peg$e109 = peg$literalExpectation("\"", false); - var peg$e110 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e111 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e112 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); - var peg$e113 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); - var peg$e114 = peg$classExpectation([","], false, false); - var peg$e115 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); + var peg$e92 = peg$literalExpectation("group-week", true); + var peg$e93 = peg$otherExpectation("operator"); + var peg$e94 = peg$classExpectation([":", "="], false, false); + var peg$e95 = peg$literalExpectation("!=", false); + var peg$e96 = peg$literalExpectation(">=", false); + var peg$e97 = peg$literalExpectation(">", false); + var peg$e98 = peg$literalExpectation("<=", false); + var peg$e99 = peg$literalExpectation("<", false); + var peg$e100 = peg$otherExpectation("word"); + var peg$e101 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e102 = peg$otherExpectation("whitespace"); + var peg$e103 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); + var peg$e104 = peg$otherExpectation("quote"); + var peg$e105 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e106 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); + var peg$e107 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); + var peg$e108 = peg$literalExpectation("\u201C", false); + var peg$e109 = peg$literalExpectation("\u201D", false); + var peg$e110 = peg$literalExpectation("\"", false); + var peg$e111 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e112 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e113 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); + var peg$e114 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); + var peg$e115 = peg$classExpectation([","], false, false); + var peg$e116 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); var peg$f0 = function(ranges) { return { autocomplete, ranges }; }; var peg$f1 = function(filters) { return filters.filter(Boolean).flat(); }; @@ -551,32 +553,33 @@ function peg$parse(input, options) { var peg$f78 = function() { return "groupCategory"; }; var peg$f79 = function() { return "groupMerchant"; }; var peg$f80 = function() { return "groupMonth"; }; - var peg$f81 = function() { return "eq"; }; - var peg$f82 = function() { return "neq"; }; - var peg$f83 = function() { return "gte"; }; - var peg$f84 = function() { return "gt"; }; - var peg$f85 = function() { return "lte"; }; - var peg$f86 = function() { return "lt"; }; - var peg$f87 = function(o) { + var peg$f81 = function() { return "groupWeek"; }; + var peg$f82 = function() { return "eq"; }; + var peg$f83 = function() { return "neq"; }; + var peg$f84 = function() { return "gte"; }; + var peg$f85 = function() { return "gt"; }; + var peg$f86 = function() { return "lte"; }; + var peg$f87 = function() { return "lt"; }; + var peg$f88 = function(o) { if (nameOperator) { expectingNestedQuote = (o === "eq"); // Use simple parser if no valid operator is found } isColumnsContext = false; return o; }; - var peg$f88 = function(chars) { return chars.join("").trim(); }; - var peg$f89 = function() { + var peg$f89 = function(chars) { return chars.join("").trim(); }; + var peg$f90 = function() { isColumnsContext = false; return "and"; }; - var peg$f90 = function() { return expectingNestedQuote; }; - var peg$f91 = function(start, inner, end) { //handle no-breaking space + var peg$f91 = function() { return expectingNestedQuote; }; + var peg$f92 = function(start, inner, end) { //handle no-breaking space return [...start, '"', ...inner, '"', ...end].join(""); }; - var peg$f92 = function(start) {return "“"}; - var peg$f93 = function(start) {return "”"}; - var peg$f94 = function(start) {return "\""}; - var peg$f95 = function(start, inner, end) { + var peg$f93 = function(start) {return "“"}; + var peg$f94 = function(start) {return "”"}; + var peg$f95 = function(start) {return "\""}; + var peg$f96 = function(start, inner, end) { return [...start, '"', ...inner, '"'].join(""); }; var peg$currPos = options.peg$currPos | 0; @@ -2381,6 +2384,9 @@ function peg$parse(input, options) { s0 = peg$parsegroupMerchant(); if (s0 === peg$FAILED) { s0 = peg$parsegroupMonth(); + if (s0 === peg$FAILED) { + s0 = peg$parsegroupWeek(); + } } } } @@ -3341,6 +3347,43 @@ function peg$parse(input, options) { return s0; } + function peg$parsegroupWeek() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 10); + if (s1.toLowerCase() === peg$c89) { + peg$currPos += 10; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e92); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parsewordBoundary(); + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = undefined; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f81(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + function peg$parseoperator() { var s0, s1; @@ -3351,81 +3394,81 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e93); } + if (peg$silentFails === 0) { peg$fail(peg$e94); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f81(); + s1 = peg$f82(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c89) { - s1 = peg$c89; + if (input.substr(peg$currPos, 2) === peg$c90) { + s1 = peg$c90; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e94); } + if (peg$silentFails === 0) { peg$fail(peg$e95); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f82(); + s1 = peg$f83(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c90) { - s1 = peg$c90; + if (input.substr(peg$currPos, 2) === peg$c91) { + s1 = peg$c91; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e95); } + if (peg$silentFails === 0) { peg$fail(peg$e96); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f83(); + s1 = peg$f84(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 62) { - s1 = peg$c91; + s1 = peg$c92; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e96); } + if (peg$silentFails === 0) { peg$fail(peg$e97); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f84(); + s1 = peg$f85(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c92) { - s1 = peg$c92; + if (input.substr(peg$currPos, 2) === peg$c93) { + s1 = peg$c93; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e97); } + if (peg$silentFails === 0) { peg$fail(peg$e98); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f85(); + s1 = peg$f86(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 60) { - s1 = peg$c93; + s1 = peg$c94; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e98); } + if (peg$silentFails === 0) { peg$fail(peg$e99); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f86(); + s1 = peg$f87(); } s0 = s1; } @@ -3436,7 +3479,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e92); } + if (peg$silentFails === 0) { peg$fail(peg$e93); } } return s0; @@ -3449,7 +3492,7 @@ function peg$parse(input, options) { s1 = peg$parseoperator(); if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f87(s1); + s1 = peg$f88(s1); } s0 = s1; @@ -3467,7 +3510,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e100); } + if (peg$silentFails === 0) { peg$fail(peg$e101); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { @@ -3477,7 +3520,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e100); } + if (peg$silentFails === 0) { peg$fail(peg$e101); } } } } else { @@ -3485,13 +3528,13 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f88(s1); + s1 = peg$f89(s1); } s0 = s1; peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e99); } + if (peg$silentFails === 0) { peg$fail(peg$e100); } } return s0; @@ -3503,7 +3546,7 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parse_(); peg$savedPos = s0; - s1 = peg$f89(); + s1 = peg$f90(); s0 = s1; return s0; @@ -3519,7 +3562,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e102); } + if (peg$silentFails === 0) { peg$fail(peg$e103); } } while (s1 !== peg$FAILED) { s0.push(s1); @@ -3528,12 +3571,12 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e102); } + if (peg$silentFails === 0) { peg$fail(peg$e103); } } } peg$silentFails--; s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e101); } + if (peg$silentFails === 0) { peg$fail(peg$e102); } return s0; } @@ -3543,7 +3586,7 @@ function peg$parse(input, options) { s0 = peg$currPos; peg$savedPos = peg$currPos; - s1 = peg$f90(); + s1 = peg$f91(); if (s1) { s1 = undefined; } else { @@ -3580,7 +3623,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } + if (peg$silentFails === 0) { peg$fail(peg$e105); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -3589,7 +3632,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } + if (peg$silentFails === 0) { peg$fail(peg$e105); } } } s2 = input.charAt(peg$currPos); @@ -3597,7 +3640,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } if (s2 !== peg$FAILED) { s3 = []; @@ -3606,7 +3649,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -3615,7 +3658,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } } s4 = input.charAt(peg$currPos); @@ -3623,7 +3666,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } if (s4 !== peg$FAILED) { s5 = []; @@ -3632,7 +3675,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e100); } + if (peg$silentFails === 0) { peg$fail(peg$e101); } } while (s6 !== peg$FAILED) { s5.push(s6); @@ -3641,11 +3684,11 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e100); } + if (peg$silentFails === 0) { peg$fail(peg$e101); } } } peg$savedPos = s0; - s0 = peg$f91(s1, s3, s5); + s0 = peg$f92(s1, s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3657,7 +3700,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } + if (peg$silentFails === 0) { peg$fail(peg$e104); } } return s0; @@ -3674,7 +3717,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } + if (peg$silentFails === 0) { peg$fail(peg$e105); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -3683,7 +3726,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } + if (peg$silentFails === 0) { peg$fail(peg$e105); } } } s2 = input.charAt(peg$currPos); @@ -3691,7 +3734,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } if (s2 !== peg$FAILED) { s3 = []; @@ -3700,7 +3743,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -3716,15 +3759,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c94; + s6 = peg$c95; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f92(s1); + s4 = peg$f93(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3747,15 +3790,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c95; + s6 = peg$c96; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { peg$fail(peg$e109); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f93(s1); + s4 = peg$f94(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3778,15 +3821,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c96; + s6 = peg$c97; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e109); } + if (peg$silentFails === 0) { peg$fail(peg$e110); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f94(s1); + s4 = peg$f95(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3805,7 +3848,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -3821,15 +3864,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c94; + s6 = peg$c95; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f92(s1); + s4 = peg$f93(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3852,15 +3895,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c95; + s6 = peg$c96; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { peg$fail(peg$e109); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f93(s1); + s4 = peg$f94(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3883,15 +3926,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c96; + s6 = peg$c97; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e109); } + if (peg$silentFails === 0) { peg$fail(peg$e110); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f94(s1); + s4 = peg$f95(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3907,7 +3950,7 @@ function peg$parse(input, options) { s4 = peg$parseclosingQuote(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f95(s1, s3, s4); + s0 = peg$f96(s1, s3, s4); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3919,7 +3962,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } + if (peg$silentFails === 0) { peg$fail(peg$e104); } } return s0; @@ -3934,7 +3977,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -3972,7 +4015,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e110); } + if (peg$silentFails === 0) { peg$fail(peg$e111); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -3981,7 +4024,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e110); } + if (peg$silentFails === 0) { peg$fail(peg$e111); } } } s2 = []; @@ -3990,7 +4033,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e111); } + if (peg$silentFails === 0) { peg$fail(peg$e112); } } while (s3 !== peg$FAILED) { s2.push(s3); @@ -3999,7 +4042,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e111); } + if (peg$silentFails === 0) { peg$fail(peg$e112); } } } s3 = []; @@ -4008,7 +4051,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e112); } + if (peg$silentFails === 0) { peg$fail(peg$e113); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -4017,7 +4060,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e112); } + if (peg$silentFails === 0) { peg$fail(peg$e113); } } } s4 = peg$parseoperator(); @@ -4036,7 +4079,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e113); } + if (peg$silentFails === 0) { peg$fail(peg$e114); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -4045,7 +4088,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e113); } + if (peg$silentFails === 0) { peg$fail(peg$e114); } } } s2 = peg$currPos; @@ -4092,7 +4135,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e114); } + if (peg$silentFails === 0) { peg$fail(peg$e115); } } } } @@ -4108,7 +4151,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e115); } + if (peg$silentFails === 0) { peg$fail(peg$e116); } } if (s0 === peg$FAILED) { s0 = peg$currPos; diff --git a/src/libs/SearchParser/searchParser.js b/src/libs/SearchParser/searchParser.js index 462409629027..998cc50d6388 100644 --- a/src/libs/SearchParser/searchParser.js +++ b/src/libs/SearchParser/searchParser.js @@ -273,14 +273,15 @@ function peg$parse(input, options) { var peg$c86 = "group-category"; var peg$c87 = "group-merchant"; var peg$c88 = "group-month"; - var peg$c89 = "!="; - var peg$c90 = ">="; - var peg$c91 = ">"; - var peg$c92 = "<="; - var peg$c93 = "<"; - var peg$c94 = "\u201C"; - var peg$c95 = "\u201D"; - var peg$c96 = "\""; + var peg$c89 = "group-week"; + var peg$c90 = "!="; + var peg$c91 = ">="; + var peg$c92 = ">"; + var peg$c93 = "<="; + var peg$c94 = "<"; + var peg$c95 = "\u201C"; + var peg$c96 = "\u201D"; + var peg$c97 = "\""; var peg$r0 = /^[^ \t\r\n\xA0]/; var peg$r1 = /^[ \t\r\n\xA0,:=<>!]/; @@ -391,30 +392,31 @@ function peg$parse(input, options) { var peg$e91 = peg$literalExpectation("group-category", true); var peg$e92 = peg$literalExpectation("group-merchant", true); var peg$e93 = peg$literalExpectation("group-month", true); - var peg$e94 = peg$otherExpectation("operator"); - var peg$e95 = peg$classExpectation([":", "="], false, false); - var peg$e96 = peg$literalExpectation("!=", false); - var peg$e97 = peg$literalExpectation(">=", false); - var peg$e98 = peg$literalExpectation(">", false); - var peg$e99 = peg$literalExpectation("<=", false); - var peg$e100 = peg$literalExpectation("<", false); - var peg$e101 = peg$otherExpectation("word"); - var peg$e102 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e103 = peg$otherExpectation("whitespace"); - var peg$e104 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); - var peg$e105 = peg$otherExpectation("quote"); - var peg$e106 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e107 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); - var peg$e108 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); - var peg$e109 = peg$literalExpectation("\u201C", false); - var peg$e110 = peg$literalExpectation("\u201D", false); - var peg$e111 = peg$literalExpectation("\"", false); - var peg$e112 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e113 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e114 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); - var peg$e115 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); - var peg$e116 = peg$classExpectation([","], false, false); - var peg$e117 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); + var peg$e94 = peg$literalExpectation("group-week", true); + var peg$e95 = peg$otherExpectation("operator"); + var peg$e96 = peg$classExpectation([":", "="], false, false); + var peg$e97 = peg$literalExpectation("!=", false); + var peg$e98 = peg$literalExpectation(">=", false); + var peg$e99 = peg$literalExpectation(">", false); + var peg$e100 = peg$literalExpectation("<=", false); + var peg$e101 = peg$literalExpectation("<", false); + var peg$e102 = peg$otherExpectation("word"); + var peg$e103 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e104 = peg$otherExpectation("whitespace"); + var peg$e105 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); + var peg$e106 = peg$otherExpectation("quote"); + var peg$e107 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e108 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); + var peg$e109 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); + var peg$e110 = peg$literalExpectation("\u201C", false); + var peg$e111 = peg$literalExpectation("\u201D", false); + var peg$e112 = peg$literalExpectation("\"", false); + var peg$e113 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e114 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e115 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); + var peg$e116 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); + var peg$e117 = peg$classExpectation([","], false, false); + var peg$e118 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); var peg$f0 = function(filters) { return applyDefaults(filters); }; var peg$f1 = function(head, tail) { @@ -578,32 +580,33 @@ function peg$parse(input, options) { var peg$f79 = function() { return "groupCategory"; }; var peg$f80 = function() { return "groupMerchant"; }; var peg$f81 = function() { return "groupMonth"; }; - var peg$f82 = function() { return "eq"; }; - var peg$f83 = function() { return "neq"; }; - var peg$f84 = function() { return "gte"; }; - var peg$f85 = function() { return "gt"; }; - var peg$f86 = function() { return "lte"; }; - var peg$f87 = function() { return "lt"; }; - var peg$f88 = function(o) { + var peg$f82 = function() { return "groupWeek"; }; + var peg$f83 = function() { return "eq"; }; + var peg$f84 = function() { return "neq"; }; + var peg$f85 = function() { return "gte"; }; + var peg$f86 = function() { return "gt"; }; + var peg$f87 = function() { return "lte"; }; + var peg$f88 = function() { return "lt"; }; + var peg$f89 = function(o) { if (nameOperator) { expectingNestedQuote = (o === "eq"); // Use simple parser if no valid operator is found } isColumnsContext = false; return o; }; - var peg$f89 = function(chars) { return chars.join("").trim(); }; - var peg$f90 = function() { + var peg$f90 = function(chars) { return chars.join("").trim(); }; + var peg$f91 = function() { isColumnsContext = false; return "and"; }; - var peg$f91 = function() { return expectingNestedQuote; }; - var peg$f92 = function(start, inner, end) { //handle no-breaking space + var peg$f92 = function() { return expectingNestedQuote; }; + var peg$f93 = function(start, inner, end) { //handle no-breaking space return [...start, '"', ...inner, '"', ...end].join(""); }; - var peg$f93 = function(start) {return "“"}; - var peg$f94 = function(start) {return "”"}; - var peg$f95 = function(start) {return "\""}; - var peg$f96 = function(start, inner, end) { + var peg$f94 = function(start) {return "“"}; + var peg$f95 = function(start) {return "”"}; + var peg$f96 = function(start) {return "\""}; + var peg$f97 = function(start, inner, end) { return [...start, '"', ...inner, '"'].join(""); }; var peg$currPos = options.peg$currPos | 0; @@ -2568,6 +2571,9 @@ function peg$parse(input, options) { s0 = peg$parsegroupMerchant(); if (s0 === peg$FAILED) { s0 = peg$parsegroupMonth(); + if (s0 === peg$FAILED) { + s0 = peg$parsegroupWeek(); + } } } } @@ -3528,6 +3534,43 @@ function peg$parse(input, options) { return s0; } + function peg$parsegroupWeek() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 10); + if (s1.toLowerCase() === peg$c89) { + peg$currPos += 10; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e94); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parsewordBoundary(); + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = undefined; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f82(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + function peg$parseoperator() { var s0, s1; @@ -3538,81 +3581,81 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e95); } + if (peg$silentFails === 0) { peg$fail(peg$e96); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f82(); + s1 = peg$f83(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c89) { - s1 = peg$c89; + if (input.substr(peg$currPos, 2) === peg$c90) { + s1 = peg$c90; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e96); } + if (peg$silentFails === 0) { peg$fail(peg$e97); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f83(); + s1 = peg$f84(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c90) { - s1 = peg$c90; + if (input.substr(peg$currPos, 2) === peg$c91) { + s1 = peg$c91; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e97); } + if (peg$silentFails === 0) { peg$fail(peg$e98); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f84(); + s1 = peg$f85(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 62) { - s1 = peg$c91; + s1 = peg$c92; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e98); } + if (peg$silentFails === 0) { peg$fail(peg$e99); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f85(); + s1 = peg$f86(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c92) { - s1 = peg$c92; + if (input.substr(peg$currPos, 2) === peg$c93) { + s1 = peg$c93; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e99); } + if (peg$silentFails === 0) { peg$fail(peg$e100); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f86(); + s1 = peg$f87(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 60) { - s1 = peg$c93; + s1 = peg$c94; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e100); } + if (peg$silentFails === 0) { peg$fail(peg$e101); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f87(); + s1 = peg$f88(); } s0 = s1; } @@ -3623,7 +3666,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e94); } + if (peg$silentFails === 0) { peg$fail(peg$e95); } } return s0; @@ -3636,7 +3679,7 @@ function peg$parse(input, options) { s1 = peg$parseoperator(); if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f88(s1); + s1 = peg$f89(s1); } s0 = s1; @@ -3654,7 +3697,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e102); } + if (peg$silentFails === 0) { peg$fail(peg$e103); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { @@ -3664,7 +3707,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e102); } + if (peg$silentFails === 0) { peg$fail(peg$e103); } } } } else { @@ -3672,13 +3715,13 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f89(s1); + s1 = peg$f90(s1); } s0 = s1; peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e101); } + if (peg$silentFails === 0) { peg$fail(peg$e102); } } return s0; @@ -3690,7 +3733,7 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parse_(); peg$savedPos = s0; - s1 = peg$f90(); + s1 = peg$f91(); s0 = s1; return s0; @@ -3706,7 +3749,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } + if (peg$silentFails === 0) { peg$fail(peg$e105); } } while (s1 !== peg$FAILED) { s0.push(s1); @@ -3715,12 +3758,12 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } + if (peg$silentFails === 0) { peg$fail(peg$e105); } } } peg$silentFails--; s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } + if (peg$silentFails === 0) { peg$fail(peg$e104); } return s0; } @@ -3730,7 +3773,7 @@ function peg$parse(input, options) { s0 = peg$currPos; peg$savedPos = peg$currPos; - s1 = peg$f91(); + s1 = peg$f92(); if (s1) { s1 = undefined; } else { @@ -3767,7 +3810,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -3776,7 +3819,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } } s2 = input.charAt(peg$currPos); @@ -3784,7 +3827,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } if (s2 !== peg$FAILED) { s3 = []; @@ -3793,7 +3836,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { peg$fail(peg$e109); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -3802,7 +3845,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { peg$fail(peg$e109); } } } s4 = input.charAt(peg$currPos); @@ -3810,7 +3853,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } if (s4 !== peg$FAILED) { s5 = []; @@ -3819,7 +3862,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e102); } + if (peg$silentFails === 0) { peg$fail(peg$e103); } } while (s6 !== peg$FAILED) { s5.push(s6); @@ -3828,11 +3871,11 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e102); } + if (peg$silentFails === 0) { peg$fail(peg$e103); } } } peg$savedPos = s0; - s0 = peg$f92(s1, s3, s5); + s0 = peg$f93(s1, s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3844,7 +3887,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } return s0; @@ -3861,7 +3904,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -3870,7 +3913,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } } s2 = input.charAt(peg$currPos); @@ -3878,7 +3921,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } if (s2 !== peg$FAILED) { s3 = []; @@ -3887,7 +3930,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { peg$fail(peg$e109); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -3903,15 +3946,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c94; + s6 = peg$c95; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e109); } + if (peg$silentFails === 0) { peg$fail(peg$e110); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f93(s1); + s4 = peg$f94(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3934,15 +3977,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c95; + s6 = peg$c96; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e110); } + if (peg$silentFails === 0) { peg$fail(peg$e111); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f94(s1); + s4 = peg$f95(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3965,15 +4008,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c96; + s6 = peg$c97; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e111); } + if (peg$silentFails === 0) { peg$fail(peg$e112); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f95(s1); + s4 = peg$f96(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3992,7 +4035,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { peg$fail(peg$e109); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -4008,15 +4051,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c94; + s6 = peg$c95; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e109); } + if (peg$silentFails === 0) { peg$fail(peg$e110); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f93(s1); + s4 = peg$f94(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4039,15 +4082,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c95; + s6 = peg$c96; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e110); } + if (peg$silentFails === 0) { peg$fail(peg$e111); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f94(s1); + s4 = peg$f95(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4070,15 +4113,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c96; + s6 = peg$c97; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e111); } + if (peg$silentFails === 0) { peg$fail(peg$e112); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f95(s1); + s4 = peg$f96(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4094,7 +4137,7 @@ function peg$parse(input, options) { s4 = peg$parseclosingQuote(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f96(s1, s3, s4); + s0 = peg$f97(s1, s3, s4); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4106,7 +4149,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } return s0; @@ -4121,7 +4164,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4159,7 +4202,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e112); } + if (peg$silentFails === 0) { peg$fail(peg$e113); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -4168,7 +4211,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e112); } + if (peg$silentFails === 0) { peg$fail(peg$e113); } } } s2 = []; @@ -4177,7 +4220,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e113); } + if (peg$silentFails === 0) { peg$fail(peg$e114); } } while (s3 !== peg$FAILED) { s2.push(s3); @@ -4186,7 +4229,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e113); } + if (peg$silentFails === 0) { peg$fail(peg$e114); } } } s3 = []; @@ -4195,7 +4238,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e114); } + if (peg$silentFails === 0) { peg$fail(peg$e115); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -4204,7 +4247,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e114); } + if (peg$silentFails === 0) { peg$fail(peg$e115); } } } s4 = peg$parseoperator(); @@ -4223,7 +4266,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e115); } + if (peg$silentFails === 0) { peg$fail(peg$e116); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -4232,7 +4275,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e115); } + if (peg$silentFails === 0) { peg$fail(peg$e116); } } } s2 = peg$currPos; @@ -4279,7 +4322,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e116); } + if (peg$silentFails === 0) { peg$fail(peg$e117); } } } } @@ -4295,7 +4338,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e117); } + if (peg$silentFails === 0) { peg$fail(peg$e118); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -4336,7 +4379,8 @@ function peg$parse(input, options) { "withdrawal-id": "desc", category: "asc", merchant: "asc", - month: "desc" + month: "desc", + week: "desc", }; const DEFAULT_SORT_BY_VALUES = new Set([...Object.values(GROUP_BY_DEFAULT_SORT), "date"]); From 7537db8422c272c22413be5531a2d2a5477ec751 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Wed, 28 Jan 2026 06:23:25 -0800 Subject: [PATCH 16/26] Prettier --- src/types/onyx/SearchResults.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/types/onyx/SearchResults.ts b/src/types/onyx/SearchResults.ts index 2ae450dccdb0..27f1e521aaf3 100644 --- a/src/types/onyx/SearchResults.ts +++ b/src/types/onyx/SearchResults.ts @@ -265,11 +265,8 @@ type SearchResults = { PrefixedRecord & PrefixedRecord & PrefixedRecord< - typeof CONST.SEARCH.GROUP_PREFIX, - - SearchMemberGroup | SearchCardGroup | SearchWithdrawalIDGroup | SearchCategoryGroup | SearchMerchantGroup | SearchTagGroup | SearchMonthGroup - | SearchWeekGroup + SearchMemberGroup | SearchCardGroup | SearchWithdrawalIDGroup | SearchCategoryGroup | SearchMerchantGroup | SearchTagGroup | SearchMonthGroup | SearchWeekGroup >; /** Whether search data is being fetched from server */ From 4634f524d8a243152c4c047432bb56113456ded6 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Wed, 28 Jan 2026 07:38:30 -0800 Subject: [PATCH 17/26] Revert unnecessary chanegs in the language files --- src/languages/ja.ts | 2 +- src/languages/pt-BR.ts | 2 +- src/languages/zh-hans.ts | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/languages/ja.ts b/src/languages/ja.ts index 835b2b93cc7a..fad21e603d8a 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -6925,7 +6925,7 @@ ${reportName} groupBy: { [CONST.SEARCH.GROUP_BY.FROM]: '送信者', [CONST.SEARCH.GROUP_BY.CARD]: 'カード', - [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: '出金 ID', + [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: '出金ID', [CONST.SEARCH.GROUP_BY.CATEGORY]: 'カテゴリー', [CONST.SEARCH.GROUP_BY.MERCHANT]: '加盟店', [CONST.SEARCH.GROUP_BY.TAG]: 'タグ', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index 4f8b353ffd5d..04b61c457a26 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -6958,7 +6958,7 @@ Exija detalhes de despesas como recibos e descrições, defina limites e padrõe groupBy: { [CONST.SEARCH.GROUP_BY.FROM]: 'De', [CONST.SEARCH.GROUP_BY.CARD]: 'Cartão', - [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'ID da saque', + [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: 'ID da retirada', [CONST.SEARCH.GROUP_BY.CATEGORY]: 'Categoria', [CONST.SEARCH.GROUP_BY.MERCHANT]: 'Comerciante', [CONST.SEARCH.GROUP_BY.TAG]: 'Etiqueta', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index a9ae23aeb8d6..a73608db44ad 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -6803,10 +6803,9 @@ ${reportName} reimbursable: '可报销', purchaseCurrency: '购买货币', groupBy: { - [CONST.SEARCH.GROUP_BY.FROM]: '发件人', + [CONST.SEARCH.GROUP_BY.FROM]: '来自', [CONST.SEARCH.GROUP_BY.CARD]: '卡片', - //_/\__/_/ \_,_/\__/\__/\_,_/ - [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: '提现编号', + [CONST.SEARCH.GROUP_BY.WITHDRAWAL_ID]: '提现 ID', [CONST.SEARCH.GROUP_BY.CATEGORY]: '类别', [CONST.SEARCH.GROUP_BY.MERCHANT]: '商家', [CONST.SEARCH.GROUP_BY.TAG]: '标签', From 875a6fa2121cd3fb2fd32e1b6714efdbba25d2df Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Wed, 28 Jan 2026 07:42:00 -0800 Subject: [PATCH 18/26] refactor --- src/libs/SearchUIUtils.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 4309c2e4f683..a70611b639e2 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -277,8 +277,7 @@ const transactionMonthGroupColumnNamesToSortingProperty: TransactionMonthGroupSo const transactionWeekGroupColumnNamesToSortingProperty: TransactionWeekGroupSorting = { [CONST.SEARCH.TABLE_COLUMNS.GROUP_WEEK]: 'week' as const, - [CONST.SEARCH.TABLE_COLUMNS.GROUP_EXPENSES]: 'count' as const, - [CONST.SEARCH.TABLE_COLUMNS.GROUP_TOTAL]: 'total' as const, + ...transactionGroupBaseSortingProperties, }; const expenseStatusActionMapping = { From e5790b840250e469bee5756c1bf45d971ed956f7 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Wed, 28 Jan 2026 07:45:17 -0800 Subject: [PATCH 19/26] Remove sortKey for weeks in tests --- tests/ui/WeekListItemHeaderTest.tsx | 1 - tests/unit/Search/SearchUIUtilsTest.ts | 20 -------------------- 2 files changed, 21 deletions(-) diff --git a/tests/ui/WeekListItemHeaderTest.tsx b/tests/ui/WeekListItemHeaderTest.tsx index 0bf16b23187f..f02864ab3fb5 100644 --- a/tests/ui/WeekListItemHeaderTest.tsx +++ b/tests/ui/WeekListItemHeaderTest.tsx @@ -59,7 +59,6 @@ const createWeekListItem = (week: string, options: Partial { total: 250, groupedBy: CONST.SEARCH.GROUP_BY.WEEK, formattedWeek: 'Week of January 25, 2026', - sortKey: '2026-01-25', transactions: [], transactionsQueryJSON: undefined, }; @@ -2823,23 +2820,6 @@ describe('SearchUIUtils', () => { expect(result.some((item) => item.formattedWeek.includes('Jun 15'))).toBe(true); }); - it('should calculate sortKey correctly for week groups', () => { - const [result] = SearchUIUtils.getSections({ - type: CONST.SEARCH.DATA_TYPES.EXPENSE, - data: searchResultsGroupByWeek.data, - currentAccountID: 2074551, - currentUserEmail: '', - translate: translateLocal, - formatPhoneNumber, - bankAccountList: {}, - groupBy: CONST.SEARCH.GROUP_BY.WEEK, - }) as [TransactionWeekGroupListItemType[], number]; - - expect(result).toHaveLength(2); - expect(result.some((item) => item.sortKey === '2026-01-25')).toBe(true); - expect(result.some((item) => item.sortKey === '2025-12-28')).toBe(true); - }); - it('should return isTransactionCategoryGroupListItemType false for non-category group items', () => { const memberItem: TransactionMemberGroupListItemType = { accountID: 123, From 7b303464eb941ee61591289dc2b0fe6f84aa3199 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Wed, 28 Jan 2026 07:55:48 -0800 Subject: [PATCH 20/26] Fix typecheck --- src/libs/SearchUIUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index a70611b639e2..c037ea1b4342 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -2456,7 +2456,6 @@ function getWeekSections(data: OnyxTypes.SearchResults['data'], queryJSON: Searc transactionsQueryJSON, ...weekGroup, formattedWeek, - sortKey: weekGroup.week, }; } } From 8fb8733f776f1315f7b03577f8194119541e9c20 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Wed, 28 Jan 2026 07:56:09 -0800 Subject: [PATCH 21/26] Refactor WeekListItemHeader --- .../Search/BaseListItemHeader.tsx | 6 +- .../Search/WeekListItemHeader.tsx | 133 +++--------------- 2 files changed, 21 insertions(+), 118 deletions(-) diff --git a/src/components/SelectionListWithSections/Search/BaseListItemHeader.tsx b/src/components/SelectionListWithSections/Search/BaseListItemHeader.tsx index 576f06511391..ceba4f113af5 100644 --- a/src/components/SelectionListWithSections/Search/BaseListItemHeader.tsx +++ b/src/components/SelectionListWithSections/Search/BaseListItemHeader.tsx @@ -30,14 +30,16 @@ type GroupColumnKey = | typeof CONST.SEARCH.TABLE_COLUMNS.GROUP_CATEGORY | typeof CONST.SEARCH.TABLE_COLUMNS.GROUP_MERCHANT | typeof CONST.SEARCH.TABLE_COLUMNS.GROUP_TAG - | typeof CONST.SEARCH.TABLE_COLUMNS.GROUP_MONTH; + | typeof CONST.SEARCH.TABLE_COLUMNS.GROUP_MONTH + | typeof CONST.SEARCH.TABLE_COLUMNS.GROUP_WEEK; /** Supported column style keys for sizing */ type ColumnStyleKey = | typeof CONST.SEARCH.TABLE_COLUMNS.CATEGORY | typeof CONST.SEARCH.TABLE_COLUMNS.MERCHANT | typeof CONST.SEARCH.TABLE_COLUMNS.TAG - | typeof CONST.SEARCH.TABLE_COLUMNS.GROUP_MONTH; + | typeof CONST.SEARCH.TABLE_COLUMNS.GROUP_MONTH + | typeof CONST.SEARCH.TABLE_COLUMNS.GROUP_WEEK; type BaseListItemHeaderProps = { /** The group item being rendered */ diff --git a/src/components/SelectionListWithSections/Search/WeekListItemHeader.tsx b/src/components/SelectionListWithSections/Search/WeekListItemHeader.tsx index d71725ead66a..680dc53f5133 100644 --- a/src/components/SelectionListWithSections/Search/WeekListItemHeader.tsx +++ b/src/components/SelectionListWithSections/Search/WeekListItemHeader.tsx @@ -1,45 +1,12 @@ import React from 'react'; -import {View} from 'react-native'; -import Checkbox from '@components/Checkbox'; -import type {SearchColumnType} from '@components/Search/types'; import type {ListItem, TransactionWeekGroupListItemType} from '@components/SelectionListWithSections/types'; -import TextWithTooltip from '@components/TextWithTooltip'; -import useLocalize from '@hooks/useLocalize'; -import useResponsiveLayout from '@hooks/useResponsiveLayout'; -import useStyleUtils from '@hooks/useStyleUtils'; -import useThemeStyles from '@hooks/useThemeStyles'; import CONST from '@src/CONST'; -import ExpandCollapseArrowButton from './ExpandCollapseArrowButton'; -import TextCell from './TextCell'; -import TotalCell from './TotalCell'; +import type {BaseListItemHeaderProps} from './BaseListItemHeader'; +import BaseListItemHeader from './BaseListItemHeader'; -type WeekListItemHeaderProps = { +type WeekListItemHeaderProps = Omit, 'item' | 'displayName' | 'groupColumnKey' | 'columnStyleKey'> & { /** The week group currently being looked at */ week: TransactionWeekGroupListItemType; - - /** Callback to fire when a checkbox is pressed */ - onCheckboxPress?: (item: TItem) => void; - - /** Whether this section items disabled for selection */ - isDisabled?: boolean | null; - - /** Whether selecting multiple transactions at once is allowed */ - canSelectMultiple: boolean | undefined; - - /** Whether all transactions are selected */ - isSelectAllChecked?: boolean; - - /** Whether only some transactions are selected */ - isIndeterminate?: boolean; - - /** Callback for when the down arrow is clicked */ - onDownArrowClick?: () => void; - - /** Whether the down arrow is expanded */ - isExpanded?: boolean; - - /** The visible columns for the header */ - columns?: SearchColumnType[]; }; function WeekListItemHeader({ @@ -53,89 +20,23 @@ function WeekListItemHeader({ onDownArrowClick, columns, }: WeekListItemHeaderProps) { - const styles = useThemeStyles(); - const StyleUtils = useStyleUtils(); - const {isLargeScreenWidth} = useResponsiveLayout(); - const {translate} = useLocalize(); const weekName = weekItem.formattedWeek; - const columnComponents = { - [CONST.SEARCH.TABLE_COLUMNS.GROUP_WEEK]: ( - - - - - - ), - [CONST.SEARCH.TABLE_COLUMNS.GROUP_EXPENSES]: ( - - - - ), - [CONST.SEARCH.TABLE_COLUMNS.GROUP_TOTAL]: ( - - - - ), - }; - return ( - - - - {!!canSelectMultiple && ( - onCheckboxPress?.(weekItem as unknown as TItem)} - isChecked={isSelectAllChecked} - isIndeterminate={isIndeterminate} - disabled={!!isDisabled || weekItem.isDisabledCheckbox} - accessibilityLabel={translate('common.select')} - style={isLargeScreenWidth && styles.mr1} - /> - )} - {!isLargeScreenWidth && ( - - - - - - )} - {isLargeScreenWidth && columns?.map((column) => columnComponents[column as keyof typeof columnComponents])} - - {!isLargeScreenWidth && ( - - - {!!onDownArrowClick && ( - - )} - - )} - - + ); } From 680f90e0a57ebc3a6bf6ee51dc01668a28c42858 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Wed, 28 Jan 2026 08:05:35 -0800 Subject: [PATCH 22/26] Refactor --- src/libs/SearchUIUtils.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index c037ea1b4342..4d485cce43cc 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -2431,9 +2431,8 @@ function getWeekSections(data: OnyxTypes.SearchResults['data'], queryJSON: Searc continue; } let transactionsQueryJSON: SearchQueryJSON | undefined; + const {start: weekStart, end: weekEnd} = DateUtils.getWeekDateRange(weekGroup.week); if (queryJSON && weekGroup.week) { - // Create date range for the week (start date to end date of the week) - const {start: weekStart, end: weekEnd} = DateUtils.getWeekDateRange(weekGroup.week); const newFlatFilters = queryJSON.flatFilters.filter((filter) => filter.key !== CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE); newFlatFilters.push({ key: CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE, @@ -2446,8 +2445,6 @@ function getWeekSections(data: OnyxTypes.SearchResults['data'], queryJSON: Searc const newQuery = buildSearchQueryString(newQueryJSON); transactionsQueryJSON = buildSearchQueryJSON(newQuery); } - - const {start: weekStart, end: weekEnd} = DateUtils.getWeekDateRange(weekGroup.week); const formattedWeek = DateUtils.getFormattedDateRangeForSearch(weekStart, weekEnd); weekSections[key] = { From bdf07760722fa87fec488f2097d14189ec3beea1 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Wed, 28 Jan 2026 12:08:53 -0800 Subject: [PATCH 23/26] fix test --- tests/unit/Search/SearchUIUtilsTest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index 38275459a61e..0a27be19a49e 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -2763,7 +2763,7 @@ describe('SearchUIUtils', () => { currency: 'USD', total: 250, groupedBy: CONST.SEARCH.GROUP_BY.WEEK, - formattedWeek: 'Week of January 25, 2026', + formattedWeek: 'Jan 25 - Jan 31, 2026', transactions: [], transactionsQueryJSON: undefined, }; From 2dd02bf9f4a354527169aa5a834e23a16afe1464 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Wed, 28 Jan 2026 12:10:50 -0800 Subject: [PATCH 24/26] Fix the week intervals when the date is limited --- src/components/Search/index.tsx | 5 +- src/libs/SearchUIUtils.ts | 143 ++++++++++++++++++++++++++++++-- 2 files changed, 140 insertions(+), 8 deletions(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 9fddfab051bf..fcdaf81d1115 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -41,6 +41,7 @@ import {isSplitAction} from '@libs/ReportSecondaryActionUtils'; import {canEditFieldOfMoneyRequest, canHoldUnholdReportAction, canRejectReportAction, isOneTransactionReport, selectFilteredReportActions} from '@libs/ReportUtils'; import {buildCannedSearchQuery, buildSearchQueryJSON, buildSearchQueryString} from '@libs/SearchQueryUtils'; import { + adjustTimeRangeToDateFilters, createAndOpenSearchTransactionThread, getColumnsToShow, getListItem, @@ -895,8 +896,10 @@ function Search({ if (!weekGroupItem.week) { return; } + // Extract the existing date filter to check for year-to-date or other date limits + const existingDateFilter = queryJSON.flatFilters.find((filter) => filter.key === CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE); + const {start: weekStart, end: weekEnd} = adjustTimeRangeToDateFilters(DateUtils.getWeekDateRange(weekGroupItem.week), existingDateFilter); const newFlatFilters = queryJSON.flatFilters.filter((filter) => filter.key !== CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE); - const {start: weekStart, end: weekEnd} = DateUtils.getWeekDateRange(weekGroupItem.week); newFlatFilters.push({ key: CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE, filters: [ diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 4d485cce43cc..8e6030acb207 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -1,6 +1,6 @@ /* eslint-disable max-lines */ // TODO: Remove this disable once SearchUIUtils is refactored (see dedicated refactor issue) -import {format} from 'date-fns'; +import {endOfMonth, format, startOfMonth, startOfYear, subMonths} from 'date-fns'; import type {TextStyle, ViewStyle} from 'react-native'; import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; @@ -11,6 +11,7 @@ import type {MenuItemWithLink} from '@components/MenuItemList'; import type {MultiSelectItem} from '@components/Search/FilterDropdowns/MultiSelectPopup'; import type {SingleSelectItem} from '@components/Search/FilterDropdowns/SingleSelectPopup'; import type { + QueryFilters, SearchAction, SearchColumnType, SearchCustomColumnIds, @@ -1391,6 +1392,7 @@ function getTransactionsSections( isActionLoadingSet: ReadonlySet | undefined, bankAccountList: OnyxEntry, reportActions: Record = {}, + queryJSON?: SearchQueryJSON, ): [TransactionListItemType[], number] { const shouldShowMerchant = getShouldShowMerchant(data); const {shouldShowYearCreated, shouldShowYearSubmitted, shouldShowYearApproved, shouldShowYearPosted, shouldShowYearExported} = shouldShowYear(data); @@ -1409,7 +1411,8 @@ function getTransactionsSections( const lastExportedActionByReportID = buildLastExportedActionByReportIDMap(data); - const queryJSON = getCurrentSearchQueryJSON(); + // Use the provided queryJSON if available, otherwise fall back to getCurrentSearchQueryJSON() + const currentQueryJSON = queryJSON ?? getCurrentSearchQueryJSON(); for (const key of transactionKeys) { const transactionItem = data[key]; @@ -1418,9 +1421,9 @@ function getTransactionsSections( let shouldShow = true; const isActionLoading = isActionLoadingSet?.has(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${transactionItem.reportID}`); - if (queryJSON && !isActionLoading) { - if (queryJSON.type === CONST.SEARCH.DATA_TYPES.EXPENSE) { - const status = queryJSON.status; + if (currentQueryJSON && !isActionLoading) { + if (currentQueryJSON.type === CONST.SEARCH.DATA_TYPES.EXPENSE) { + const status = currentQueryJSON.status; if (Array.isArray(status)) { shouldShow = status.some((expenseStatus) => { return isValidExpenseStatus(expenseStatus) ? expenseStatusActionMapping[expenseStatus](report) : false; @@ -2431,7 +2434,10 @@ function getWeekSections(data: OnyxTypes.SearchResults['data'], queryJSON: Searc continue; } let transactionsQueryJSON: SearchQueryJSON | undefined; - const {start: weekStart, end: weekEnd} = DateUtils.getWeekDateRange(weekGroup.week); + const {start: weekStart, end: weekEnd} = adjustTimeRangeToDateFilters( + DateUtils.getWeekDateRange(weekGroup.week), + queryJSON?.flatFilters.find((filter) => filter.key === CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE), + ); if (queryJSON && weekGroup.week) { const newFlatFilters = queryJSON.flatFilters.filter((filter) => filter.key !== CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE); newFlatFilters.push({ @@ -2547,7 +2553,7 @@ function getSections({ } } - return getTransactionsSections(data, currentSearch, currentAccountID, currentUserEmail, formatPhoneNumber, isActionLoadingSet, bankAccountList, reportActions); + return getTransactionsSections(data, currentSearch, currentAccountID, currentUserEmail, formatPhoneNumber, isActionLoadingSet, bankAccountList, reportActions, queryJSON); } /** @@ -4085,6 +4091,128 @@ function getTableMinWidth(columns: SearchColumnType[]) { return minWidth; } +/** + * Converts a date preset string to actual date range + */ +function getDateRangeForPreset(preset: SearchDatePreset): {start: string; end: string} { + const now = new Date(); + let start: Date; + let end: Date; + + switch (preset) { + case CONST.SEARCH.DATE_PRESETS.THIS_MONTH: + start = startOfMonth(now); + end = endOfMonth(now); + break; + case CONST.SEARCH.DATE_PRESETS.LAST_MONTH: + const lastMonth = subMonths(now, 1); + start = startOfMonth(lastMonth); + end = endOfMonth(lastMonth); + break; + case CONST.SEARCH.DATE_PRESETS.YEAR_TO_DATE: + start = startOfYear(now); + end = now; + break; + default: + // For other presets or unknown values, return empty range (will be ignored) + return {start: '', end: ''}; + } + + return { + start: format(start, 'yyyy-MM-dd'), + end: format(end, 'yyyy-MM-dd'), + }; +} + +/** + * Checks if a string value is a date preset + */ +function isDatePreset(value: string | number | undefined): value is SearchDatePreset { + if (typeof value !== 'string') { + return false; + } + return Object.values(CONST.SEARCH.DATE_PRESETS).some((datePreset) => datePreset === value); +} + +function adjustTimeRangeToDateFilters(timeRange: {start: string; end: string}, dateFilter: QueryFilters[0] | undefined): {start: string; end: string} { + if (!dateFilter || !dateFilter.filters) { + return timeRange; + } + + const {start: timeRangeStart, end: timeRangeEnd} = timeRange; + const startLimitFilter = dateFilter.filters.find((filter) => filter.operator === CONST.SEARCH.SYNTAX_OPERATORS.GREATER_THAN_OR_EQUAL_TO); + const endLimitFilter = dateFilter.filters.find((filter) => filter.operator === CONST.SEARCH.SYNTAX_OPERATORS.LOWER_THAN_OR_EQUAL_TO); + const equalToFilter = dateFilter.filters.find((filter) => filter.operator === CONST.SEARCH.SYNTAX_OPERATORS.EQUAL_TO); + + // Check if any filter value is a date preset and convert it to actual date range + let limitsStart: string | undefined; + let limitsEnd: string | undefined; + + // Handle GREATER_THAN_OR_EQUAL_TO operator + if (startLimitFilter?.value) { + const value = String(startLimitFilter.value); + if (isDatePreset(value)) { + const presetRange = getDateRangeForPreset(value); + limitsStart = presetRange.start || undefined; + } else { + limitsStart = value; + } + } + + // Handle LOWER_THAN_OR_EQUAL_TO operator + if (endLimitFilter?.value) { + const value = String(endLimitFilter.value); + if (isDatePreset(value)) { + const presetRange = getDateRangeForPreset(value); + limitsEnd = presetRange.end || undefined; + } else { + limitsEnd = value; + } + } + + // Handle EQUAL_TO operator (for presets like "this-month", "last-month", "year-to-date") + if (equalToFilter?.value) { + const value = String(equalToFilter.value); + if (isDatePreset(value)) { + const presetRange = getDateRangeForPreset(value); + if (presetRange.start && presetRange.end) { + // If we don't have start/end limits yet, use the preset range + if (!limitsStart) { + limitsStart = presetRange.start; + } + if (!limitsEnd) { + limitsEnd = presetRange.end; + } + // If we have both limits, use the intersection (max start, min end) + if (limitsStart && presetRange.start > limitsStart) { + limitsStart = presetRange.start; + } + if (limitsEnd && presetRange.end < limitsEnd) { + limitsEnd = presetRange.end; + } + } + } + } + + // Adjust the start date: use max(timeRangeStart, limitsStart) if limitsStart exists + // Dates are in YYYY-MM-DD format, so lexicographic comparison works correctly + let adjustedStart = timeRangeStart; + if (limitsStart && limitsStart > timeRangeStart) { + adjustedStart = limitsStart; + } + + // Adjust the end date: use min(timeRangeEnd, limitsEnd) if limitsEnd exists + let adjustedEnd = timeRangeEnd; + if (limitsEnd && limitsEnd < timeRangeEnd) { + adjustedEnd = limitsEnd; + } + + return { + start: adjustedStart, + end: adjustedEnd, + }; +} + export { getSuggestedSearches, getDefaultActionableSearchMenuItem, @@ -4140,5 +4268,6 @@ export { getCustomColumnDefault, getToFieldValueForTransaction, isTodoSearch, + adjustTimeRangeToDateFilters, }; export type {SavedSearchMenuItem, SearchTypeMenuSection, SearchTypeMenuItem, SearchDateModifier, SearchDateModifierLower, SearchKey, ArchivedReportsIDSet}; From b35710cd4230ad62c43e673c39db5114c174d869 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Wed, 28 Jan 2026 12:19:36 -0800 Subject: [PATCH 25/26] Regenerate after resolving conflicts --- src/libs/SearchParser/autocompleteParser.js | 291 +++++++++++--------- src/libs/SearchParser/searchParser.js | 291 +++++++++++--------- 2 files changed, 334 insertions(+), 248 deletions(-) diff --git a/src/libs/SearchParser/autocompleteParser.js b/src/libs/SearchParser/autocompleteParser.js index eb73ff9aa89f..df1170954c7f 100644 --- a/src/libs/SearchParser/autocompleteParser.js +++ b/src/libs/SearchParser/autocompleteParser.js @@ -273,14 +273,15 @@ function peg$parse(input, options) { var peg$c87 = "group-tag"; var peg$c88 = "group-merchant"; var peg$c89 = "group-month"; - var peg$c90 = "!="; - var peg$c91 = ">="; - var peg$c92 = ">"; - var peg$c93 = "<="; - var peg$c94 = "<"; - var peg$c95 = "\u201C"; - var peg$c96 = "\u201D"; - var peg$c97 = "\""; + var peg$c90 = "group-week"; + var peg$c91 = "!="; + var peg$c92 = ">="; + var peg$c93 = ">"; + var peg$c94 = "<="; + var peg$c95 = "<"; + var peg$c96 = "\u201C"; + var peg$c97 = "\u201D"; + var peg$c98 = "\""; var peg$r0 = /^[ \t\r\n\xA0,:=<>!]/; var peg$r1 = /^[:=]/; @@ -389,30 +390,31 @@ function peg$parse(input, options) { var peg$e90 = peg$literalExpectation("group-tag", true); var peg$e91 = peg$literalExpectation("group-merchant", true); var peg$e92 = peg$literalExpectation("group-month", true); - var peg$e93 = peg$otherExpectation("operator"); - var peg$e94 = peg$classExpectation([":", "="], false, false); - var peg$e95 = peg$literalExpectation("!=", false); - var peg$e96 = peg$literalExpectation(">=", false); - var peg$e97 = peg$literalExpectation(">", false); - var peg$e98 = peg$literalExpectation("<=", false); - var peg$e99 = peg$literalExpectation("<", false); - var peg$e100 = peg$otherExpectation("word"); - var peg$e101 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e102 = peg$otherExpectation("whitespace"); - var peg$e103 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); - var peg$e104 = peg$otherExpectation("quote"); - var peg$e105 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e106 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); - var peg$e107 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); - var peg$e108 = peg$literalExpectation("\u201C", false); - var peg$e109 = peg$literalExpectation("\u201D", false); - var peg$e110 = peg$literalExpectation("\"", false); - var peg$e111 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e112 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e113 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); - var peg$e114 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); - var peg$e115 = peg$classExpectation([","], false, false); - var peg$e116 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); + var peg$e93 = peg$literalExpectation("group-week", true); + var peg$e94 = peg$otherExpectation("operator"); + var peg$e95 = peg$classExpectation([":", "="], false, false); + var peg$e96 = peg$literalExpectation("!=", false); + var peg$e97 = peg$literalExpectation(">=", false); + var peg$e98 = peg$literalExpectation(">", false); + var peg$e99 = peg$literalExpectation("<=", false); + var peg$e100 = peg$literalExpectation("<", false); + var peg$e101 = peg$otherExpectation("word"); + var peg$e102 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e103 = peg$otherExpectation("whitespace"); + var peg$e104 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); + var peg$e105 = peg$otherExpectation("quote"); + var peg$e106 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e107 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); + var peg$e108 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); + var peg$e109 = peg$literalExpectation("\u201C", false); + var peg$e110 = peg$literalExpectation("\u201D", false); + var peg$e111 = peg$literalExpectation("\"", false); + var peg$e112 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e113 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e114 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); + var peg$e115 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); + var peg$e116 = peg$classExpectation([","], false, false); + var peg$e117 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); var peg$f0 = function(ranges) { return { autocomplete, ranges }; }; var peg$f1 = function(filters) { return filters.filter(Boolean).flat(); }; @@ -554,32 +556,33 @@ function peg$parse(input, options) { var peg$f79 = function() { return "groupTag"; }; var peg$f80 = function() { return "groupMerchant"; }; var peg$f81 = function() { return "groupMonth"; }; - var peg$f82 = function() { return "eq"; }; - var peg$f83 = function() { return "neq"; }; - var peg$f84 = function() { return "gte"; }; - var peg$f85 = function() { return "gt"; }; - var peg$f86 = function() { return "lte"; }; - var peg$f87 = function() { return "lt"; }; - var peg$f88 = function(o) { + var peg$f82 = function() { return "groupWeek"; }; + var peg$f83 = function() { return "eq"; }; + var peg$f84 = function() { return "neq"; }; + var peg$f85 = function() { return "gte"; }; + var peg$f86 = function() { return "gt"; }; + var peg$f87 = function() { return "lte"; }; + var peg$f88 = function() { return "lt"; }; + var peg$f89 = function(o) { if (nameOperator) { expectingNestedQuote = (o === "eq"); // Use simple parser if no valid operator is found } isColumnsContext = false; return o; }; - var peg$f89 = function(chars) { return chars.join("").trim(); }; - var peg$f90 = function() { + var peg$f90 = function(chars) { return chars.join("").trim(); }; + var peg$f91 = function() { isColumnsContext = false; return "and"; }; - var peg$f91 = function() { return expectingNestedQuote; }; - var peg$f92 = function(start, inner, end) { //handle no-breaking space + var peg$f92 = function() { return expectingNestedQuote; }; + var peg$f93 = function(start, inner, end) { //handle no-breaking space return [...start, '"', ...inner, '"', ...end].join(""); }; - var peg$f93 = function(start) {return "“"}; - var peg$f94 = function(start) {return "”"}; - var peg$f95 = function(start) {return "\""}; - var peg$f96 = function(start, inner, end) { + var peg$f94 = function(start) {return "“"}; + var peg$f95 = function(start) {return "”"}; + var peg$f96 = function(start) {return "\""}; + var peg$f97 = function(start, inner, end) { return [...start, '"', ...inner, '"'].join(""); }; var peg$currPos = options.peg$currPos | 0; @@ -2386,6 +2389,9 @@ function peg$parse(input, options) { s0 = peg$parsegroupMerchant(); if (s0 === peg$FAILED) { s0 = peg$parsegroupMonth(); + if (s0 === peg$FAILED) { + s0 = peg$parsegroupWeek(); + } } } } @@ -3384,6 +3390,43 @@ function peg$parse(input, options) { return s0; } + function peg$parsegroupWeek() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 10); + if (s1.toLowerCase() === peg$c90) { + peg$currPos += 10; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e93); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parsewordBoundary(); + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = undefined; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f82(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + function peg$parseoperator() { var s0, s1; @@ -3394,81 +3437,81 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e94); } + if (peg$silentFails === 0) { peg$fail(peg$e95); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f82(); + s1 = peg$f83(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c90) { - s1 = peg$c90; + if (input.substr(peg$currPos, 2) === peg$c91) { + s1 = peg$c91; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e95); } + if (peg$silentFails === 0) { peg$fail(peg$e96); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f83(); + s1 = peg$f84(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c91) { - s1 = peg$c91; + if (input.substr(peg$currPos, 2) === peg$c92) { + s1 = peg$c92; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e96); } + if (peg$silentFails === 0) { peg$fail(peg$e97); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f84(); + s1 = peg$f85(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 62) { - s1 = peg$c92; + s1 = peg$c93; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e97); } + if (peg$silentFails === 0) { peg$fail(peg$e98); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f85(); + s1 = peg$f86(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c93) { - s1 = peg$c93; + if (input.substr(peg$currPos, 2) === peg$c94) { + s1 = peg$c94; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e98); } + if (peg$silentFails === 0) { peg$fail(peg$e99); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f86(); + s1 = peg$f87(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 60) { - s1 = peg$c94; + s1 = peg$c95; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e99); } + if (peg$silentFails === 0) { peg$fail(peg$e100); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f87(); + s1 = peg$f88(); } s0 = s1; } @@ -3479,7 +3522,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e93); } + if (peg$silentFails === 0) { peg$fail(peg$e94); } } return s0; @@ -3492,7 +3535,7 @@ function peg$parse(input, options) { s1 = peg$parseoperator(); if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f88(s1); + s1 = peg$f89(s1); } s0 = s1; @@ -3510,7 +3553,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e101); } + if (peg$silentFails === 0) { peg$fail(peg$e102); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { @@ -3520,7 +3563,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e101); } + if (peg$silentFails === 0) { peg$fail(peg$e102); } } } } else { @@ -3528,13 +3571,13 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f89(s1); + s1 = peg$f90(s1); } s0 = s1; peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e100); } + if (peg$silentFails === 0) { peg$fail(peg$e101); } } return s0; @@ -3546,7 +3589,7 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parse_(); peg$savedPos = s0; - s1 = peg$f90(); + s1 = peg$f91(); s0 = s1; return s0; @@ -3562,7 +3605,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } + if (peg$silentFails === 0) { peg$fail(peg$e104); } } while (s1 !== peg$FAILED) { s0.push(s1); @@ -3571,12 +3614,12 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } + if (peg$silentFails === 0) { peg$fail(peg$e104); } } } peg$silentFails--; s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e102); } + if (peg$silentFails === 0) { peg$fail(peg$e103); } return s0; } @@ -3586,7 +3629,7 @@ function peg$parse(input, options) { s0 = peg$currPos; peg$savedPos = peg$currPos; - s1 = peg$f91(); + s1 = peg$f92(); if (s1) { s1 = undefined; } else { @@ -3623,7 +3666,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -3632,7 +3675,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } } s2 = input.charAt(peg$currPos); @@ -3640,7 +3683,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } if (s2 !== peg$FAILED) { s3 = []; @@ -3649,7 +3692,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -3658,7 +3701,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } } s4 = input.charAt(peg$currPos); @@ -3666,7 +3709,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } if (s4 !== peg$FAILED) { s5 = []; @@ -3675,7 +3718,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e101); } + if (peg$silentFails === 0) { peg$fail(peg$e102); } } while (s6 !== peg$FAILED) { s5.push(s6); @@ -3684,11 +3727,11 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e101); } + if (peg$silentFails === 0) { peg$fail(peg$e102); } } } peg$savedPos = s0; - s0 = peg$f92(s1, s3, s5); + s0 = peg$f93(s1, s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3700,7 +3743,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } + if (peg$silentFails === 0) { peg$fail(peg$e105); } } return s0; @@ -3717,7 +3760,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -3726,7 +3769,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } } s2 = input.charAt(peg$currPos); @@ -3734,7 +3777,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } if (s2 !== peg$FAILED) { s3 = []; @@ -3743,7 +3786,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -3759,15 +3802,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c95; + s6 = peg$c96; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { peg$fail(peg$e109); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f93(s1); + s4 = peg$f94(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3790,15 +3833,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c96; + s6 = peg$c97; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e109); } + if (peg$silentFails === 0) { peg$fail(peg$e110); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f94(s1); + s4 = peg$f95(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3821,15 +3864,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c97; + s6 = peg$c98; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e110); } + if (peg$silentFails === 0) { peg$fail(peg$e111); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f95(s1); + s4 = peg$f96(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3848,7 +3891,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -3864,15 +3907,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c95; + s6 = peg$c96; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { peg$fail(peg$e109); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f93(s1); + s4 = peg$f94(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3895,15 +3938,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c96; + s6 = peg$c97; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e109); } + if (peg$silentFails === 0) { peg$fail(peg$e110); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f94(s1); + s4 = peg$f95(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3926,15 +3969,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c97; + s6 = peg$c98; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e110); } + if (peg$silentFails === 0) { peg$fail(peg$e111); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f95(s1); + s4 = peg$f96(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3950,7 +3993,7 @@ function peg$parse(input, options) { s4 = peg$parseclosingQuote(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f96(s1, s3, s4); + s0 = peg$f97(s1, s3, s4); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3962,7 +4005,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } + if (peg$silentFails === 0) { peg$fail(peg$e105); } } return s0; @@ -3977,7 +4020,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4015,7 +4058,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e111); } + if (peg$silentFails === 0) { peg$fail(peg$e112); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -4024,7 +4067,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e111); } + if (peg$silentFails === 0) { peg$fail(peg$e112); } } } s2 = []; @@ -4033,7 +4076,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e112); } + if (peg$silentFails === 0) { peg$fail(peg$e113); } } while (s3 !== peg$FAILED) { s2.push(s3); @@ -4042,7 +4085,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e112); } + if (peg$silentFails === 0) { peg$fail(peg$e113); } } } s3 = []; @@ -4051,7 +4094,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e113); } + if (peg$silentFails === 0) { peg$fail(peg$e114); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -4060,7 +4103,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e113); } + if (peg$silentFails === 0) { peg$fail(peg$e114); } } } s4 = peg$parseoperator(); @@ -4079,7 +4122,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e114); } + if (peg$silentFails === 0) { peg$fail(peg$e115); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -4088,7 +4131,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e114); } + if (peg$silentFails === 0) { peg$fail(peg$e115); } } } s2 = peg$currPos; @@ -4135,7 +4178,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e115); } + if (peg$silentFails === 0) { peg$fail(peg$e116); } } } } @@ -4151,7 +4194,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e116); } + if (peg$silentFails === 0) { peg$fail(peg$e117); } } if (s0 === peg$FAILED) { s0 = peg$currPos; diff --git a/src/libs/SearchParser/searchParser.js b/src/libs/SearchParser/searchParser.js index 9c771de5d48c..0b307d3b01d9 100644 --- a/src/libs/SearchParser/searchParser.js +++ b/src/libs/SearchParser/searchParser.js @@ -274,14 +274,15 @@ function peg$parse(input, options) { var peg$c87 = "group-tag"; var peg$c88 = "group-merchant"; var peg$c89 = "group-month"; - var peg$c90 = "!="; - var peg$c91 = ">="; - var peg$c92 = ">"; - var peg$c93 = "<="; - var peg$c94 = "<"; - var peg$c95 = "\u201C"; - var peg$c96 = "\u201D"; - var peg$c97 = "\""; + var peg$c90 = "group-week"; + var peg$c91 = "!="; + var peg$c92 = ">="; + var peg$c93 = ">"; + var peg$c94 = "<="; + var peg$c95 = "<"; + var peg$c96 = "\u201C"; + var peg$c97 = "\u201D"; + var peg$c98 = "\""; var peg$r0 = /^[^ \t\r\n\xA0]/; var peg$r1 = /^[ \t\r\n\xA0,:=<>!]/; @@ -393,30 +394,31 @@ function peg$parse(input, options) { var peg$e92 = peg$literalExpectation("group-tag", true); var peg$e93 = peg$literalExpectation("group-merchant", true); var peg$e94 = peg$literalExpectation("group-month", true); - var peg$e95 = peg$otherExpectation("operator"); - var peg$e96 = peg$classExpectation([":", "="], false, false); - var peg$e97 = peg$literalExpectation("!=", false); - var peg$e98 = peg$literalExpectation(">=", false); - var peg$e99 = peg$literalExpectation(">", false); - var peg$e100 = peg$literalExpectation("<=", false); - var peg$e101 = peg$literalExpectation("<", false); - var peg$e102 = peg$otherExpectation("word"); - var peg$e103 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e104 = peg$otherExpectation("whitespace"); - var peg$e105 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); - var peg$e106 = peg$otherExpectation("quote"); - var peg$e107 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); - var peg$e108 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); - var peg$e109 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); - var peg$e110 = peg$literalExpectation("\u201C", false); - var peg$e111 = peg$literalExpectation("\u201D", false); - var peg$e112 = peg$literalExpectation("\"", false); - var peg$e113 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e114 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); - var peg$e115 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); - var peg$e116 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); - var peg$e117 = peg$classExpectation([","], false, false); - var peg$e118 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); + var peg$e95 = peg$literalExpectation("group-week", true); + var peg$e96 = peg$otherExpectation("operator"); + var peg$e97 = peg$classExpectation([":", "="], false, false); + var peg$e98 = peg$literalExpectation("!=", false); + var peg$e99 = peg$literalExpectation(">=", false); + var peg$e100 = peg$literalExpectation(">", false); + var peg$e101 = peg$literalExpectation("<=", false); + var peg$e102 = peg$literalExpectation("<", false); + var peg$e103 = peg$otherExpectation("word"); + var peg$e104 = peg$classExpectation([" ", ",", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e105 = peg$otherExpectation("whitespace"); + var peg$e106 = peg$classExpectation([" ", "\t", "\r", "\n", "\xA0"], false, false); + var peg$e107 = peg$otherExpectation("quote"); + var peg$e108 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r", "\xA0"], true, false); + var peg$e109 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false); + var peg$e110 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false); + var peg$e111 = peg$literalExpectation("\u201C", false); + var peg$e112 = peg$literalExpectation("\u201D", false); + var peg$e113 = peg$literalExpectation("\"", false); + var peg$e114 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e115 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false); + var peg$e116 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0"], false, false); + var peg$e117 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false); + var peg$e118 = peg$classExpectation([","], false, false); + var peg$e119 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false); var peg$f0 = function(filters) { return applyDefaults(filters); }; var peg$f1 = function(head, tail) { @@ -581,32 +583,33 @@ function peg$parse(input, options) { var peg$f80 = function() { return "groupTag"; }; var peg$f81 = function() { return "groupMerchant"; }; var peg$f82 = function() { return "groupMonth"; }; - var peg$f83 = function() { return "eq"; }; - var peg$f84 = function() { return "neq"; }; - var peg$f85 = function() { return "gte"; }; - var peg$f86 = function() { return "gt"; }; - var peg$f87 = function() { return "lte"; }; - var peg$f88 = function() { return "lt"; }; - var peg$f89 = function(o) { + var peg$f83 = function() { return "groupWeek"; }; + var peg$f84 = function() { return "eq"; }; + var peg$f85 = function() { return "neq"; }; + var peg$f86 = function() { return "gte"; }; + var peg$f87 = function() { return "gt"; }; + var peg$f88 = function() { return "lte"; }; + var peg$f89 = function() { return "lt"; }; + var peg$f90 = function(o) { if (nameOperator) { expectingNestedQuote = (o === "eq"); // Use simple parser if no valid operator is found } isColumnsContext = false; return o; }; - var peg$f90 = function(chars) { return chars.join("").trim(); }; - var peg$f91 = function() { + var peg$f91 = function(chars) { return chars.join("").trim(); }; + var peg$f92 = function() { isColumnsContext = false; return "and"; }; - var peg$f92 = function() { return expectingNestedQuote; }; - var peg$f93 = function(start, inner, end) { //handle no-breaking space + var peg$f93 = function() { return expectingNestedQuote; }; + var peg$f94 = function(start, inner, end) { //handle no-breaking space return [...start, '"', ...inner, '"', ...end].join(""); }; - var peg$f94 = function(start) {return "“"}; - var peg$f95 = function(start) {return "”"}; - var peg$f96 = function(start) {return "\""}; - var peg$f97 = function(start, inner, end) { + var peg$f95 = function(start) {return "“"}; + var peg$f96 = function(start) {return "”"}; + var peg$f97 = function(start) {return "\""}; + var peg$f98 = function(start, inner, end) { return [...start, '"', ...inner, '"'].join(""); }; var peg$currPos = options.peg$currPos | 0; @@ -2573,6 +2576,9 @@ function peg$parse(input, options) { s0 = peg$parsegroupMerchant(); if (s0 === peg$FAILED) { s0 = peg$parsegroupMonth(); + if (s0 === peg$FAILED) { + s0 = peg$parsegroupWeek(); + } } } } @@ -3571,6 +3577,43 @@ function peg$parse(input, options) { return s0; } + function peg$parsegroupWeek() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = input.substr(peg$currPos, 10); + if (s1.toLowerCase() === peg$c90) { + peg$currPos += 10; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e95); } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + peg$silentFails++; + s3 = peg$parsewordBoundary(); + peg$silentFails--; + if (s3 !== peg$FAILED) { + peg$currPos = s2; + s2 = undefined; + } else { + s2 = peg$FAILED; + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f83(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + + return s0; + } + function peg$parseoperator() { var s0, s1; @@ -3581,81 +3624,81 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e96); } + if (peg$silentFails === 0) { peg$fail(peg$e97); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f83(); + s1 = peg$f84(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c90) { - s1 = peg$c90; + if (input.substr(peg$currPos, 2) === peg$c91) { + s1 = peg$c91; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e97); } + if (peg$silentFails === 0) { peg$fail(peg$e98); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f84(); + s1 = peg$f85(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c91) { - s1 = peg$c91; + if (input.substr(peg$currPos, 2) === peg$c92) { + s1 = peg$c92; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e98); } + if (peg$silentFails === 0) { peg$fail(peg$e99); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f85(); + s1 = peg$f86(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 62) { - s1 = peg$c92; + s1 = peg$c93; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e99); } + if (peg$silentFails === 0) { peg$fail(peg$e100); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f86(); + s1 = peg$f87(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c93) { - s1 = peg$c93; + if (input.substr(peg$currPos, 2) === peg$c94) { + s1 = peg$c94; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e100); } + if (peg$silentFails === 0) { peg$fail(peg$e101); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f87(); + s1 = peg$f88(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 60) { - s1 = peg$c94; + s1 = peg$c95; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e101); } + if (peg$silentFails === 0) { peg$fail(peg$e102); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f88(); + s1 = peg$f89(); } s0 = s1; } @@ -3666,7 +3709,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e95); } + if (peg$silentFails === 0) { peg$fail(peg$e96); } } return s0; @@ -3679,7 +3722,7 @@ function peg$parse(input, options) { s1 = peg$parseoperator(); if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f89(s1); + s1 = peg$f90(s1); } s0 = s1; @@ -3697,7 +3740,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } + if (peg$silentFails === 0) { peg$fail(peg$e104); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { @@ -3707,7 +3750,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } + if (peg$silentFails === 0) { peg$fail(peg$e104); } } } } else { @@ -3715,13 +3758,13 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f90(s1); + s1 = peg$f91(s1); } s0 = s1; peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e102); } + if (peg$silentFails === 0) { peg$fail(peg$e103); } } return s0; @@ -3733,7 +3776,7 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parse_(); peg$savedPos = s0; - s1 = peg$f91(); + s1 = peg$f92(); s0 = s1; return s0; @@ -3749,7 +3792,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } while (s1 !== peg$FAILED) { s0.push(s1); @@ -3758,12 +3801,12 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } + if (peg$silentFails === 0) { peg$fail(peg$e106); } } } peg$silentFails--; s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } + if (peg$silentFails === 0) { peg$fail(peg$e105); } return s0; } @@ -3773,7 +3816,7 @@ function peg$parse(input, options) { s0 = peg$currPos; peg$savedPos = peg$currPos; - s1 = peg$f92(); + s1 = peg$f93(); if (s1) { s1 = undefined; } else { @@ -3810,7 +3853,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -3819,7 +3862,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } } s2 = input.charAt(peg$currPos); @@ -3827,7 +3870,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { peg$fail(peg$e109); } } if (s2 !== peg$FAILED) { s3 = []; @@ -3836,7 +3879,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e109); } + if (peg$silentFails === 0) { peg$fail(peg$e110); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -3845,7 +3888,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e109); } + if (peg$silentFails === 0) { peg$fail(peg$e110); } } } s4 = input.charAt(peg$currPos); @@ -3853,7 +3896,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { peg$fail(peg$e109); } } if (s4 !== peg$FAILED) { s5 = []; @@ -3862,7 +3905,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } + if (peg$silentFails === 0) { peg$fail(peg$e104); } } while (s6 !== peg$FAILED) { s5.push(s6); @@ -3871,11 +3914,11 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } + if (peg$silentFails === 0) { peg$fail(peg$e104); } } } peg$savedPos = s0; - s0 = peg$f93(s1, s3, s5); + s0 = peg$f94(s1, s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3887,7 +3930,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } return s0; @@ -3904,7 +3947,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -3913,7 +3956,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } + if (peg$silentFails === 0) { peg$fail(peg$e108); } } } s2 = input.charAt(peg$currPos); @@ -3921,7 +3964,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { peg$fail(peg$e109); } } if (s2 !== peg$FAILED) { s3 = []; @@ -3930,7 +3973,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e109); } + if (peg$silentFails === 0) { peg$fail(peg$e110); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -3946,15 +3989,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c95; + s6 = peg$c96; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e110); } + if (peg$silentFails === 0) { peg$fail(peg$e111); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f94(s1); + s4 = peg$f95(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -3977,15 +4020,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c96; + s6 = peg$c97; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e111); } + if (peg$silentFails === 0) { peg$fail(peg$e112); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f95(s1); + s4 = peg$f96(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4008,15 +4051,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c97; + s6 = peg$c98; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e112); } + if (peg$silentFails === 0) { peg$fail(peg$e113); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f96(s1); + s4 = peg$f97(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4035,7 +4078,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e109); } + if (peg$silentFails === 0) { peg$fail(peg$e110); } } if (s4 === peg$FAILED) { s4 = peg$currPos; @@ -4051,15 +4094,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8220) { - s6 = peg$c95; + s6 = peg$c96; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e110); } + if (peg$silentFails === 0) { peg$fail(peg$e111); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f94(s1); + s4 = peg$f95(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4082,15 +4125,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 8221) { - s6 = peg$c96; + s6 = peg$c97; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e111); } + if (peg$silentFails === 0) { peg$fail(peg$e112); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f95(s1); + s4 = peg$f96(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4113,15 +4156,15 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c97; + s6 = peg$c98; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e112); } + if (peg$silentFails === 0) { peg$fail(peg$e113); } } if (s6 !== peg$FAILED) { peg$savedPos = s4; - s4 = peg$f96(s1); + s4 = peg$f97(s1); } else { peg$currPos = s4; s4 = peg$FAILED; @@ -4137,7 +4180,7 @@ function peg$parse(input, options) { s4 = peg$parseclosingQuote(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f97(s1, s3, s4); + s0 = peg$f98(s1, s3, s4); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -4149,7 +4192,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } + if (peg$silentFails === 0) { peg$fail(peg$e107); } } return s0; @@ -4164,7 +4207,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } + if (peg$silentFails === 0) { peg$fail(peg$e109); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; @@ -4202,7 +4245,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e113); } + if (peg$silentFails === 0) { peg$fail(peg$e114); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -4211,7 +4254,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e113); } + if (peg$silentFails === 0) { peg$fail(peg$e114); } } } s2 = []; @@ -4220,7 +4263,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e114); } + if (peg$silentFails === 0) { peg$fail(peg$e115); } } while (s3 !== peg$FAILED) { s2.push(s3); @@ -4229,7 +4272,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e114); } + if (peg$silentFails === 0) { peg$fail(peg$e115); } } } s3 = []; @@ -4238,7 +4281,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e115); } + if (peg$silentFails === 0) { peg$fail(peg$e116); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -4247,7 +4290,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e115); } + if (peg$silentFails === 0) { peg$fail(peg$e116); } } } s4 = peg$parseoperator(); @@ -4266,7 +4309,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e116); } + if (peg$silentFails === 0) { peg$fail(peg$e117); } } while (s2 !== peg$FAILED) { s1.push(s2); @@ -4275,7 +4318,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e116); } + if (peg$silentFails === 0) { peg$fail(peg$e117); } } } s2 = peg$currPos; @@ -4322,7 +4365,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e117); } + if (peg$silentFails === 0) { peg$fail(peg$e118); } } } } @@ -4338,7 +4381,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e118); } + if (peg$silentFails === 0) { peg$fail(peg$e119); } } if (s0 === peg$FAILED) { s0 = peg$currPos; From 326300229fa1686555ba154c39f8d2ea0e25f528 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Wed, 28 Jan 2026 13:15:31 -0800 Subject: [PATCH 26/26] Fix eslint --- src/libs/SearchUIUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index ece227d098db..1438d9db000f 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -4125,6 +4125,7 @@ function getDateRangeForPreset(preset: SearchDatePreset): {start: string; end: s const now = new Date(); let start: Date; let end: Date; + const lastMonth = subMonths(now, 1); switch (preset) { case CONST.SEARCH.DATE_PRESETS.THIS_MONTH: @@ -4132,7 +4133,6 @@ function getDateRangeForPreset(preset: SearchDatePreset): {start: string; end: s end = endOfMonth(now); break; case CONST.SEARCH.DATE_PRESETS.LAST_MONTH: - const lastMonth = subMonths(now, 1); start = startOfMonth(lastMonth); end = endOfMonth(lastMonth); break; @@ -4162,7 +4162,7 @@ function isDatePreset(value: string | number | undefined): value is SearchDatePr } function adjustTimeRangeToDateFilters(timeRange: {start: string; end: string}, dateFilter: QueryFilters[0] | undefined): {start: string; end: string} { - if (!dateFilter || !dateFilter.filters) { + if (!dateFilter?.filters) { return timeRange; }