From 545040b79893b37aaca81535a64b6688401d1c15 Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Mon, 24 Nov 2025 23:54:37 +0530
Subject: [PATCH 1/3] Populate advance filter amounts for negative expenses

---
 src/libs/SearchQueryUtils.ts              |  8 +++----
 tests/unit/Search/SearchQueryUtilsTest.ts | 27 +++++++++++++++++++++++
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/src/libs/SearchQueryUtils.ts b/src/libs/SearchQueryUtils.ts
index fc52585c16f7..8778303ae5db 100644
--- a/src/libs/SearchQueryUtils.ts
+++ b/src/libs/SearchQueryUtils.ts
@@ -811,19 +811,19 @@ function buildFilterFormValuesFromQuery(
             // backend amount is an integer and is 2 digits longer than frontend amount
             filtersForm[equalToKey] =
                 filterList
-                    .find((filter) => filter.operator === CONST.SEARCH.SYNTAX_OPERATORS.EQUAL_TO && validateAmount(filter.value.toString(), 0, CONST.IOU.AMOUNT_MAX_LENGTH + 2))
+                    .find((filter) => filter.operator === CONST.SEARCH.SYNTAX_OPERATORS.EQUAL_TO && validateAmount(filter.value.toString(), 0, CONST.IOU.AMOUNT_MAX_LENGTH + 2, true))
                     ?.value.toString() ?? filtersForm[equalToKey];
             filtersForm[lessThanKey] =
                 filterList
-                    .find((filter) => filter.operator === CONST.SEARCH.SYNTAX_OPERATORS.LOWER_THAN && validateAmount(filter.value.toString(), 0, CONST.IOU.AMOUNT_MAX_LENGTH + 2))
+                    .find((filter) => filter.operator === CONST.SEARCH.SYNTAX_OPERATORS.LOWER_THAN && validateAmount(filter.value.toString(), 0, CONST.IOU.AMOUNT_MAX_LENGTH + 2, true))
                     ?.value.toString() ?? filtersForm[lessThanKey];
             filtersForm[greaterThanKey] =
                 filterList
-                    .find((filter) => filter.operator === CONST.SEARCH.SYNTAX_OPERATORS.GREATER_THAN && validateAmount(filter.value.toString(), 0, CONST.IOU.AMOUNT_MAX_LENGTH + 2))
+                    .find((filter) => filter.operator === CONST.SEARCH.SYNTAX_OPERATORS.GREATER_THAN && validateAmount(filter.value.toString(), 0, CONST.IOU.AMOUNT_MAX_LENGTH + 2, true))
                     ?.value.toString() ?? filtersForm[greaterThanKey];
             filtersForm[negatedKey] =
                 filterList
-                    .find((filter) => filter.operator === CONST.SEARCH.SYNTAX_OPERATORS.NOT_EQUAL_TO && validateAmount(filter.value.toString(), 0, CONST.IOU.AMOUNT_MAX_LENGTH + 2))
+                    .find((filter) => filter.operator === CONST.SEARCH.SYNTAX_OPERATORS.NOT_EQUAL_TO && validateAmount(filter.value.toString(), 0, CONST.IOU.AMOUNT_MAX_LENGTH + 2, true))
                     ?.value.toString() ?? filtersForm[negatedKey];
         }
 
diff --git a/tests/unit/Search/SearchQueryUtilsTest.ts b/tests/unit/Search/SearchQueryUtilsTest.ts
index 6b6001116118..87841d88084d 100644
--- a/tests/unit/Search/SearchQueryUtilsTest.ts
+++ b/tests/unit/Search/SearchQueryUtilsTest.ts
@@ -335,6 +335,33 @@ describe('SearchQueryUtils', () => {
                 action: undefined,
             });
         });
+
+        test('parses negative backend amounts into filter form values', () => {
+            const policyCategories = {};
+            const policyTags = {};
+            const currencyList = {};
+            const personalDetails = {};
+            const cardList = {};
+            const reports = {};
+            const taxRates = {};
+
+            const queryString = 'sortBy:date sortOrder:desc type:expense amount<-12345 amount>-67890 amount:-54321';
+            const queryJSON = buildSearchQueryJSON(queryString);
+
+            if (!queryJSON) {
+                throw new Error('Failed to parse query string');
+            }
+
+            const result = buildFilterFormValuesFromQuery(queryJSON, policyCategories, policyTags, currencyList, personalDetails, cardList, reports, taxRates);
+
+            expect(result).toMatchObject({
+                type: 'expense',
+                status: CONST.SEARCH.STATUS.EXPENSE.ALL,
+                amountLessThan: '-12345',
+                amountGreaterThan: '-67890',
+                amountEqualTo: '-54321',
+            });
+        });
     });
 
     describe('shouldHighlight', () => {

From ad257d770af4d0ae3686ca97b28bf3cf9a16e6fc Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Tue, 25 Nov 2025 00:12:18 +0530
Subject: [PATCH 2/3] Use toEqual

---
 tests/unit/Search/SearchQueryUtilsTest.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/unit/Search/SearchQueryUtilsTest.ts b/tests/unit/Search/SearchQueryUtilsTest.ts
index 87841d88084d..60fc4c3fa861 100644
--- a/tests/unit/Search/SearchQueryUtilsTest.ts
+++ b/tests/unit/Search/SearchQueryUtilsTest.ts
@@ -354,7 +354,7 @@ describe('SearchQueryUtils', () => {
 
             const result = buildFilterFormValuesFromQuery(queryJSON, policyCategories, policyTags, currencyList, personalDetails, cardList, reports, taxRates);
 
-            expect(result).toMatchObject({
+            expect(result).toEqual({
                 type: 'expense',
                 status: CONST.SEARCH.STATUS.EXPENSE.ALL,
                 amountLessThan: '-12345',

From 600f6e940257f438c193f19773fb11b113e0b207 Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Thu, 27 Nov 2025 01:23:47 +0530
Subject: [PATCH 3/3] Add support for negative values in the input field

---
 src/components/Search/SearchFiltersAmountBase.tsx | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/components/Search/SearchFiltersAmountBase.tsx b/src/components/Search/SearchFiltersAmountBase.tsx
index d7baaf1ca2f7..f5658923fc4b 100644
--- a/src/components/Search/SearchFiltersAmountBase.tsx
+++ b/src/components/Search/SearchFiltersAmountBase.tsx
@@ -222,6 +222,7 @@ function SearchFiltersAmountBase({title, filterKey, testID}: {title: Translation
                         role={CONST.ROLE.PRESENTATION}
                         ref={inputCallbackRef}
                         inputMode={CONST.INPUT_MODE.DECIMAL}
+                        shouldAllowNegative
                         autoFocus
                         uncontrolled
                     />
