Skip to content

[BUG]: Smart Batch Suggestions ignore active filters and select invoices hidden from the table #331

Open

Description

@Mansi2007275

Bug Description

Describe the bug

Batch suggestions on the Received Invoices page are computed once, from the whole fetched page (findBatchSuggestions(decryptedInvoices)), and stored in state. They never take the active filters into account.

With a filter applied:

  1. Suggestions are still shown for invoices that the filter hides.
  2. Clicking Select & Pay selects those hidden invoices.
  3. The selection-pruning effect only runs when filteredAndSortedInvoices changes, so the hidden ids stay selected.
  4. Pay Selected (N) and the batch payment then include invoices that the user cannot see in the table.

File: frontend/src/page/ReceivedInvoice.jsx

Steps to reproduce

  1. Receive 2+ invoices from the same sender on the same day in token A, plus some invoices in token B.
  2. On the Received Invoices page, filter by token B.
  3. The suggestion for token A is still visible. Click Select & Pay.
  4. The selected count now includes token A invoices that are not shown in the table, and paying sends funds for them.

Expected behavior

Suggestions should only be built from the invoices currently visible after filtering, so a user never pays for an invoice they can't see.

Proposed fix

Derive the suggestions from the filtered list instead of storing them at fetch time:

const batchSuggestions = useMemo(
  () => findBatchSuggestions(filteredAndSortedInvoices),
  [filteredAndSortedInvoices]
);

and remove the batchSuggestions state and its setBatchSuggestions(...) calls.

I would like to work on this issue.

Steps to Reproduce

No response

Logs and Screenshots

No response

Environment Details

No response

Impact

Critical - Application is unusable

Code of Conduct

  • I have joined the Discord server and will post updates there
  • I have searched existing issues to avoid duplicates

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions