-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[HOLD][Insights][Release 9] Seed Spend over time suggested search #81070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -752,6 +752,33 @@ function getSuggestedSearches( | |
| CONST.SEARCH.GROUP_BY.MERCHANT, | ||
| CONST.SEARCH.TOP_SEARCH_LIMIT, | ||
| ), | ||
| [CONST.SEARCH.SEARCH_KEYS.SPEND_OVER_TIME]: { | ||
| key: CONST.SEARCH.SEARCH_KEYS.SPEND_OVER_TIME, | ||
| translationPath: 'search.spendOverTime', | ||
| type: CONST.SEARCH.DATA_TYPES.EXPENSE, | ||
| icon: 'Receipt', | ||
| searchQuery: buildQueryStringFromFilterFormValues( | ||
| { | ||
| type: CONST.SEARCH.DATA_TYPES.EXPENSE, | ||
| groupBy: CONST.SEARCH.GROUP_BY.MONTH, | ||
| dateOn: CONST.SEARCH.DATE_PRESETS.YEAR_TO_DATE, | ||
| view: CONST.SEARCH.VIEW.BAR, | ||
| }, | ||
| { | ||
| sortBy: CONST.SEARCH.TABLE_COLUMNS.GROUP_MONTH, | ||
| sortOrder: CONST.SEARCH.SORT_ORDER.DESC, | ||
| }, | ||
| ), | ||
| get searchQueryJSON() { | ||
| return buildSearchQueryJSON(this.searchQuery); | ||
| }, | ||
| get hash() { | ||
| return this.searchQueryJSON?.hash ?? CONST.DEFAULT_NUMBER_ID; | ||
| }, | ||
| get similarSearchHash() { | ||
| return this.searchQueryJSON?.similarSearchHash ?? CONST.DEFAULT_NUMBER_ID; | ||
| }, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
|
|
@@ -776,6 +803,7 @@ function getSuggestedSearchesVisibility( | |
| let shouldShowTopSpendersSuggestion = false; | ||
| let shouldShowTopCategoriesSuggestion = false; | ||
| let shouldShowTopMerchantsSuggestion = false; | ||
| let shouldShowSpendOverTimeSuggestion = false; | ||
|
|
||
| const hasCardFeed = Object.values(cardFeedsByPolicy ?? {}).some((feeds) => feeds.length > 0); | ||
|
|
||
|
|
@@ -814,6 +842,7 @@ function getSuggestedSearchesVisibility( | |
| const isEligibleForTopSpendersSuggestion = isPaidPolicy && (isAdmin || isAuditor || isApprover); | ||
| const isEligibleForTopCategoriesSuggestion = isPaidPolicy && policy.areCategoriesEnabled === true; | ||
| const isEligibleForTopMerchantsSuggestion = isPaidPolicy; | ||
| const isEligibleForSpendOverTimeSuggestion = isPaidPolicy && (isAdmin || isAuditor || isApprover); | ||
|
|
||
| shouldShowSubmitSuggestion ||= isEligibleForSubmitSuggestion; | ||
| shouldShowPaySuggestion ||= isEligibleForPaySuggestion; | ||
|
|
@@ -826,6 +855,7 @@ function getSuggestedSearchesVisibility( | |
| shouldShowTopSpendersSuggestion ||= isEligibleForTopSpendersSuggestion; | ||
| shouldShowTopCategoriesSuggestion ||= isEligibleForTopCategoriesSuggestion; | ||
| shouldShowTopMerchantsSuggestion ||= isEligibleForTopMerchantsSuggestion; | ||
| shouldShowSpendOverTimeSuggestion ||= isEligibleForSpendOverTimeSuggestion; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ PERF-2 (docs)The early return optimization in the Issue: After adding the new Fix: Add return (
shouldShowSubmitSuggestion &&
// ... other conditions ...
shouldShowTopMerchantsSuggestion &&
shouldShowSpendOverTimeSuggestion // Add this
);Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency. |
||
|
|
||
| // We don't need to check the rest of the policies if we already determined that all suggestions should be displayed | ||
| return ( | ||
|
|
@@ -858,6 +888,7 @@ function getSuggestedSearchesVisibility( | |
| [CONST.SEARCH.SEARCH_KEYS.TOP_SPENDERS]: shouldShowTopSpendersSuggestion, | ||
| [CONST.SEARCH.SEARCH_KEYS.TOP_CATEGORIES]: shouldShowTopCategoriesSuggestion, | ||
| [CONST.SEARCH.SEARCH_KEYS.TOP_MERCHANTS]: shouldShowTopMerchantsSuggestion, | ||
| [CONST.SEARCH.SEARCH_KEYS.SPEND_OVER_TIME]: shouldShowSpendOverTimeSuggestion, | ||
| }; | ||
| } | ||
|
|
||
|
|
@@ -3626,7 +3657,12 @@ function createTypeMenuSections( | |
| menuItems: [], | ||
| }; | ||
|
|
||
| const insightsSearchKeys = [CONST.SEARCH.SEARCH_KEYS.TOP_SPENDERS, CONST.SEARCH.SEARCH_KEYS.TOP_CATEGORIES, CONST.SEARCH.SEARCH_KEYS.TOP_MERCHANTS]; | ||
| const insightsSearchKeys = [ | ||
| CONST.SEARCH.SEARCH_KEYS.TOP_SPENDERS, | ||
| CONST.SEARCH.SEARCH_KEYS.TOP_CATEGORIES, | ||
| CONST.SEARCH.SEARCH_KEYS.TOP_MERCHANTS, | ||
| CONST.SEARCH.SEARCH_KEYS.SPEND_OVER_TIME, | ||
| ]; | ||
|
|
||
| for (const key of insightsSearchKeys) { | ||
| if (!suggestedSearchesVisibility[key]) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding
LINEtoCONST.SEARCH.VIEWmakes “Line” appear in the view picker becausegetViewOptionsmapsObject.values(CONST.SEARCH.VIEW). However, chart rendering only supports bar charts (shouldShowChartViewchecksview === BAR, andSearchChartViewmaps only BAR), so selecting “Line” will silently fall back to the table view instead of a line chart. This is a user-visible regression introduced by this commit: users can now choose a view that is not implemented. Consider keepingLINEout of the selectable views until a line chart renderer is wired up or gating it behind a feature flag.Useful? React with 👍 / 👎.