Skip to content

fix(filters): only include amount_filter when values are non-null#4928

Open
XyneSpaces wants to merge 1 commit into
mainfrom
fix/4190-amount-filter-null-payload
Open

fix(filters): only include amount_filter when values are non-null#4928
XyneSpaces wants to merge 1 commit into
mainfrom
fix/4190-amount-filter-null-payload

Conversation

@XyneSpaces

Copy link
Copy Markdown
Collaborator

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

The amount_filter object with start_amount and end_amount set 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.createAmountQuery was creating the amount_filter object 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:

  • Added check to verify if at least one of start_amount or end_amount has a non-null value
  • Only creates the amount_filter object when hasAmountValue is true
  • Maintains all existing validation and encoding logic

After Fix

Queries without amount filter now exclude the amount_filter key 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?

  • Created queries with no amount filter - verified amount_filter key is not present
  • Created queries with start_amount only - verified amount_filter contains correct value
  • Created queries with end_amount only - verified amount_filter contains correct value
  • Created queries with both values - verified amount_filter contains both correct values
  • Verified existing amount filter validation continues to work correctly
  • Build passed: npm run re:build && npm run build:prod

Where to test it?

  • INTEG
  • SANDBOX
  • PROD

Checklist

  • I ran npm run re:build
  • I reviewed submitted code
  • I added unit tests for my changes where possible

@XyneSpaces XyneSpaces requested a review from a team as a code owner June 5, 2026 10:51
@semanticdiff-com

Copy link
Copy Markdown

Review changes with  SemanticDiff

@github-actions github-actions Bot added the R-ready-for-review PR is ready for reviewing label Jun 5, 2026

@XyneSpaces XyneSpaces left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 XyneSpaces left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: ✅ Approve

🚨 0 critical · ⚠️ 0 warning · 💡 0 suggestion · 🔍 0 nitpick

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 {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

R-ready-for-review PR is ready for reviewing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Amount filter payload

1 participant