Keep rejected statements in the vault inbox
Summary
Rejecting a suggested account on an unmatched statement no longer makes the statement vanish from Statement Vault. It stays in the Unmatched inbox with a "Rejected" badge, where it can be found and deleted, so its file no longer sits unreachable while counting toward storage and blocking re-uploads as a duplicate.
Fixes jaysbeekay/sure#417
Fork pre-flight for upstream we-promise/sure#3700. Upstream PR: https://github.com/we-promise/sure/pull/4299 (same branch, same commit). Base is mirror/upstream-main at the same commit as upstream main (d55eac220), so the diff is what upstream will see; the upstream PR will be opened from this same branch and commit.
What changed
-
b77ea9bdcKeep rejected statements in the vault inbox -
AccountStatement: newinboxscope,where(account_id: nil).where(review_status: %w[unmatched rejected]). -
AccountStatementsController#index: the Unmatched inbox paginatesinboxinstead ofunmatched. -
account_statements/index.html.erb: a rejected row's suggestion cell shows the existingaccount_statement_status_badge("Rejected") instead of "No suggestion". -
Tests: one controller test, one model test.
Demo data
No demo data needed: the change is a listing fix for an existing state, reached by clicking Reject on any suggested statement.
Screenshots
Unmatched inbox after clicking Reject suggestion on checking-2026-04.csv. The statement stays listed with the Rejected badge and its View action; the row below still has a live suggestion for comparison. Captured from a system-test browser session at b77ea9bdc.
Light

Dark

Migration notes
No migration. Rows already in this state (account_id: nil, review_status: rejected) appear in the inbox as soon as this deploys, so affected users can delete them from the UI.
Verification
- Fail-first on
upstream/main(d55eac220):rejected statement stays in the inbox where it can be deletedfound the row before the reject and 0 rows after it.inbox holds every accountless statement, including rejected suggestionserrored withNoMethodError(no scope). - Mutations, each failing at least one test: index back to
unmatched(controller test); scope withoutrejected(both); scope withoutaccount_id: nil(model test); badge branch removed (controller test). bin/rails test test/controllers/account_statements_controller_test.rb test/models/account_statement_test.rb test/models/account_statement: 88 runs, 0 failures.bin/rails test(full): 11544 runs, 1 failure, 0 errors, 34 skips. The failure isSnaptradeAccount::ActivitiesProcessorTest#test_calculates_realized_gain/loss_for_option_buy_and_sell_using_per-contract_prices(expected 7000.00, got 6999.79). It fails identically on unmodifiedupstream/maind55eac220and touches nothing in this diff. Already tracked upstream as we-promise/sure#4144.- Fork CI at
b77ea9bdc:test_unitfails on that same single test only (11544 runs, 1 failure, 0 errors);test_system,lint,lint_js,scan_ruby,scan_jsand Codacy green. cubic did not review: monthly line limit reached until 1 November. bin/rubocop(changed files): no offenses.bundle exec erb_lint app/views/account_statements/index.html.erb: no errors.npm run lint: not applicable, no JavaScript changed.bin/brakeman --no-pager: 0 warnings.
Blast radius
unmatchedscope is unchanged. Its other readers,AccountStatement::Coverage#default_expected_start_monthand#ambiguous_statement_scope, both filterwhere(suggested_account: account), whichreject_match!clears, so rejected rows never reached them either way. The model test pins thatunmatchedstill excludes rejected rows.- Linked list (
with_account) is unchanged. A rejected row later given an account through the metadata form keepsreview_status: rejected(sync_review_statusreturns early for rejected) and appears under Linked; theaccount_id: nilguard ininboxkeeps it out of the inbox, so nothing is listed twice. The model test covers that row. - Duplicate detection (
duplicate_for) and@total_storage_bytesare deliberately unchanged: once the row is visible, both are reporting a real stored file. - Out of scope, from the Gatekeeper review on #417:
pdf_importsisdependent: :restrict_with_error, so a statement that already has PDF imports still cannot be destroyed. That is pre-existing and unchanged here.