Skip to content

Commit 38b403f

Browse files
authored
Merge pull request #79714 from Expensify/cmartins-revert-77957
Revert "fix: Expense still shown in Submit section after being submitted offline"
2 parents b9aaf66 + aa43bda commit 38b403f

File tree

3 files changed

+0
-94
lines changed

3 files changed

+0
-94
lines changed

src/components/MoneyRequestReportView/MoneyRequestReportNavigation.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ function MoneyRequestReportNavigation({reportID, shouldDisplayNarrowVersion}: Mo
5656
archivedReportsIDList: archivedReportsIdSet,
5757
isActionLoadingSet,
5858
cardFeeds,
59-
shouldSkipActionFiltering: true,
6059
});
6160
results = getSortedSections(type, status ?? '', searchData, localeCompare, translate, sortBy, sortOrder, groupBy).map((value) => value.reportID);
6261
}

src/libs/SearchUIUtils.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ type GetReportSectionsParams = {
157157
allTransactionViolations: OnyxCollection<OnyxTypes.TransactionViolation[]>;
158158
bankAccountList: OnyxEntry<OnyxTypes.BankAccountList>;
159159
reportActions?: Record<string, OnyxTypes.ReportAction[]>;
160-
shouldSkipActionFiltering?: boolean;
161160
};
162161

163162
const transactionColumnNamesToSortingProperty: TransactionSorting = {
@@ -244,21 +243,10 @@ const expenseStatusActionMapping = {
244243
[CONST.SEARCH.STATUS.EXPENSE.ALL]: () => true,
245244
};
246245

247-
const actionFilterMapping = {
248-
[CONST.SEARCH.ACTION_FILTERS.SUBMIT]: expenseStatusActionMapping[CONST.SEARCH.STATUS.EXPENSE.DRAFTS],
249-
[CONST.SEARCH.ACTION_FILTERS.APPROVE]: expenseStatusActionMapping[CONST.SEARCH.STATUS.EXPENSE.OUTSTANDING],
250-
[CONST.SEARCH.ACTION_FILTERS.PAY]: expenseStatusActionMapping[CONST.SEARCH.STATUS.EXPENSE.APPROVED],
251-
[CONST.SEARCH.ACTION_FILTERS.EXPORT]: () => true,
252-
};
253-
254246
function isValidExpenseStatus(status: unknown): status is ValueOf<typeof CONST.SEARCH.STATUS.EXPENSE> {
255247
return typeof status === 'string' && status in expenseStatusActionMapping;
256248
}
257249

258-
function isValidActionFilter(action: unknown): action is ValueOf<typeof CONST.SEARCH.ACTION_FILTERS> {
259-
return typeof action === 'string' && action in actionFilterMapping;
260-
}
261-
262250
function getExpenseStatusOptions(translate: LocalizedTranslate): Array<MultiSelectItem<SingularSearchStatus>> {
263251
return [
264252
{text: translate('common.unreported'), value: CONST.SEARCH.STATUS.EXPENSE.UNREPORTED},
@@ -379,7 +367,6 @@ type GetSectionsParams = {
379367
isActionLoadingSet?: ReadonlySet<string>;
380368
cardFeeds?: OnyxCollection<OnyxTypes.CardFeeds>;
381369
allTransactionViolations?: OnyxCollection<OnyxTypes.TransactionViolation[]>;
382-
shouldSkipActionFiltering?: boolean;
383370
};
384371

385372
/**
@@ -1730,7 +1717,6 @@ function getReportSections({
17301717
allTransactionViolations,
17311718
bankAccountList,
17321719
reportActions = {},
1733-
shouldSkipActionFiltering = false,
17341720
}: GetReportSectionsParams): [TransactionGroupListItemType[], number] {
17351721
const shouldShowMerchant = getShouldShowMerchant(data);
17361722

@@ -1795,11 +1781,6 @@ function getReportSections({
17951781
shouldShow = isValidExpenseStatus(status) ? expenseStatusActionMapping[status](reportItem) : false;
17961782
}
17971783
}
1798-
const actionFromQuery = queryJSON?.flatFilters?.find((filter) => filter.key === CONST.SEARCH.SYNTAX_FILTER_KEYS.ACTION)?.filters?.at(0)?.value;
1799-
1800-
if (!shouldSkipActionFiltering && actionFromQuery && isValidActionFilter(actionFromQuery)) {
1801-
shouldShow = shouldShow && actionFilterMapping[actionFromQuery](reportItem);
1802-
}
18031784
}
18041785

18051786
if (shouldShow) {
@@ -2114,7 +2095,6 @@ function getSections({
21142095
isActionLoadingSet,
21152096
cardFeeds,
21162097
allTransactionViolations,
2117-
shouldSkipActionFiltering,
21182098
}: GetSectionsParams) {
21192099
if (type === CONST.SEARCH.DATA_TYPES.CHAT) {
21202100
return getReportActionsSections(data);
@@ -2136,7 +2116,6 @@ function getSections({
21362116
allTransactionViolations,
21372117
bankAccountList,
21382118
reportActions,
2139-
shouldSkipActionFiltering,
21402119
});
21412120
}
21422121

tests/unit/Search/SearchUIUtilsTest.ts

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {setOptimisticDataForTransactionThreadPreview} from '@userActions/Search'
2525
import CONST from '@src/CONST';
2626
import IntlStore from '@src/languages/IntlStore';
2727
import type {CardFeedForDisplay} from '@src/libs/CardFeedUtils';
28-
import * as SearchQueryUtils from '@src/libs/SearchQueryUtils';
2928
import * as SearchUIUtils from '@src/libs/SearchUIUtils';
3029
import ONYXKEYS from '@src/ONYXKEYS';
3130
import ROUTES from '@src/ROUTES';
@@ -49,10 +48,6 @@ jest.mock('@userActions/Search', () => ({
4948
...jest.requireActual<typeof SearchUtils>('@userActions/Search'),
5049
setOptimisticDataForTransactionThreadPreview: jest.fn(),
5150
}));
52-
jest.mock('@src/libs/SearchQueryUtils', () => ({
53-
...jest.requireActual<typeof SearchQueryUtils>('@src/libs/SearchQueryUtils'),
54-
getCurrentSearchQueryJSON: jest.fn(),
55-
}));
5651

5752
const adminAccountID = 18439984;
5853
const adminEmail = 'admin@policy.com';
@@ -2241,73 +2236,6 @@ describe('SearchUIUtils', () => {
22412236
});
22422237
});
22432238

2244-
describe('Test getSections with shouldSkipActionFiltering option', () => {
2245-
beforeEach(() => {
2246-
// Mock getCurrentSearchQueryJSON to return a query with action filter
2247-
(SearchQueryUtils.getCurrentSearchQueryJSON as jest.Mock).mockReturnValue({
2248-
type: 'expense-report',
2249-
filters: {
2250-
operator: 'and',
2251-
left: {operator: 'eq', left: 'action', right: 'approve'},
2252-
},
2253-
flatFilters: [
2254-
{
2255-
key: 'action',
2256-
filters: [{operator: 'eq', value: 'approve'}],
2257-
},
2258-
],
2259-
});
2260-
});
2261-
2262-
afterEach(() => {
2263-
(SearchQueryUtils.getCurrentSearchQueryJSON as jest.Mock).mockClear();
2264-
});
2265-
2266-
it('should return all expense reports when shouldSkipActionFiltering is true', () => {
2267-
const result = SearchUIUtils.getSections({
2268-
type: CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT,
2269-
data: searchResults.data,
2270-
currentAccountID: 2074551,
2271-
currentUserEmail: '',
2272-
translate: translateLocal,
2273-
formatPhoneNumber,
2274-
bankAccountList: {},
2275-
shouldSkipActionFiltering: true,
2276-
})[0] as TransactionGroupListItemType[];
2277-
2278-
expect(result.length).toBe(4); // All expense reports returned
2279-
});
2280-
2281-
it('should return only filtered expense reports when shouldSkipActionFiltering is false', () => {
2282-
const result = SearchUIUtils.getSections({
2283-
type: CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT,
2284-
data: searchResults.data,
2285-
currentAccountID: 2074551,
2286-
currentUserEmail: '',
2287-
translate: translateLocal,
2288-
formatPhoneNumber,
2289-
bankAccountList: {},
2290-
shouldSkipActionFiltering: false,
2291-
})[0] as TransactionGroupListItemType[];
2292-
2293-
expect(result.length).toBe(2); // Only filtered expense reports returned
2294-
});
2295-
2296-
it('should apply default filtering behavior when shouldSkipActionFiltering is undefined', () => {
2297-
const result = SearchUIUtils.getSections({
2298-
type: CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT,
2299-
data: searchResults.data,
2300-
currentAccountID: 2074551,
2301-
currentUserEmail: '',
2302-
translate: translateLocal,
2303-
formatPhoneNumber,
2304-
bankAccountList: {},
2305-
})[0] as TransactionGroupListItemType[];
2306-
2307-
expect(result.length).toBe(2); // Default behavior applies filtering
2308-
});
2309-
});
2310-
23112239
describe('Test getSortedSections', () => {
23122240
it('should return getSortedReportActionData result when type is CHAT', () => {
23132241
const sortedActions = SearchUIUtils.getSortedSections(

0 commit comments

Comments
 (0)