fix(filters): only include amount_filter when values are non-null#4928
fix(filters): only include amount_filter when values are non-null#4928XyneSpaces wants to merge 1 commit into
Conversation
XyneSpaces
left a comment
There was a problem hiding this comment.
Review Summary
Classification: Bugfix — Amount Filter Null Payload Fix
Risk Level: Low
Files Changed: 1 file (AmountFilterUtils.res)
Verification Against Control Center Checklist
Tier 1 — High Signal:
✅ Naming Consistency — Variable names startAmount, endAmount, hasAmountValue follow camelCase convention
✅ Logic Correctness — The check startAmount->Option.isSome || endAmount->Option.isSome correctly identifies when at least one value is present
✅ Consistency — Matches behavior of other filters (status, currency, connector) that only appear when they have values
✅ Backward Compatibility — Preserves existing validation and encoding logic
Findings
None. Clean bugfix that addresses the root cause described in the PR body.
Verdict: ✅ Approve — Simple, targeted fix that prevents null amount_filter objects from being sent in API requests.
XyneSpaces
left a comment
There was a problem hiding this comment.
Verdict: ✅ Approve
🚨 0 critical ·
Classification: Bugfix — Amount filter null handling
Risk: Low
Clean targeted fix addressing Issue #4190. The change correctly ensures amount_filter is only included in the filter JSON when at least one of start_amount or end_amount has a non-null value. This matches the behavior of other filters (status, currency, connector) that only appear when they have actual values.
| // Only create amount_filter if at least one value is non-null | ||
| let hasAmountValue = startAmount->Option.isSome || endAmount->Option.isSome | ||
|
|
||
| if hasAmountValue { |
There was a problem hiding this comment.
💡 The logic correctly uses Option.isSome to check for non-null values. However, since the amount field uses numericTextInput(~precision=2), verify that 0.00 or empty string values are handled consistently — empty numeric fields often deserialize as None but sometimes as Some(0.0).
Test edge case: clear both amount fields and submit — confirm amount_filter is absent, not {"start_amount": 0, "end_amount": 0}.
Type of Change
Description
The
amount_filterobject withstart_amountandend_amountset to null was always being included in the filter JSON, even when the amount filter wasn't being used. This is inconsistent with other filters (like status, currency, connector) which only appear in the filter JSON when they have actual values.Root Cause
AmountFilterUtils.createAmountQuerywas creating theamount_filterobject whenever validation passed, regardless of whether the amount values were null or not. This meant that queries without any amount filter still contained:{ "amount_filter": { "start_amount": null, "end_amount": null } }Changes
Modified
src/screens/Transaction/CommonFilters/AmountFilter/AmountFilterUtils.res:start_amountorend_amounthas a non-null valueamount_filterobject whenhasAmountValueis trueAfter Fix
Queries without amount filter now exclude the
amount_filterkey entirely, matching the behavior of other filters.Closes #4190
Motivation and Context
Other filters (status, currency, connector) only appear in the filter JSON when they have actual values. The amount filter should follow the same pattern for consistency and to avoid sending unnecessary null objects in API requests.
How did you test it?
amount_filterkey is not presentstart_amountonly - verifiedamount_filtercontains correct valueend_amountonly - verifiedamount_filtercontains correct valueamount_filtercontains both correct valuesnpm run re:build && npm run build:prodWhere to test it?
Checklist
npm run re:build