Skip to content

Fix payee/category is nothing rules not applying correctly - #7531

Closed
sk10727-a11y wants to merge 5 commits into
actualbudget:masterfrom
jadenar07:fix-rules-nothing-payee
Closed

sk10727-a11y wants to merge 5 commits into
actualbudget:masterfrom
jadenar07:fix-rules-nothing-payee

Conversation

@sk10727-a11y

@sk10727-a11y sk10727-a11y commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes an issue where "payee is blank, set payee" or "category is blank, set category" were not being enforced correctly. Transactions missing those fields were not matching the rule condition as expected, causing the action to be skipped.

This change normalizes missing ID fields during rule matching, so blank payee and blank category conditions are handled consistently.

Related issue(s)

Fixes #5724

Testing

Tested rule behavior for "is nothing" conditions across different flows by creating two rules: payee is nothing → set payee and category is nothing → set category. Tested both rules in both the All Accounts view and individual account views.

Verified that the rules applied automatically for new transactions in both views. No regressions observed for other rule conditions.

Notes

  • As a result of this fix, rules targeting blank fields (e.g. "payee is blank") will now correctly apply during manual transaction entry, since missing values are normalized during rule evaluation.

  • For testing:

    • In "All Accounts", rules trigger as long as required fields like date and account are set.
    • In a specific account view, transactions must have a nonzero amount before rules are applied.

Checklist

  • Release notes added (see link above)
  • No obvious regressions in affected areas
  • Self-review has been performed - I understand what each change in the code does and why it is needed

Bundle Stats

Bundle Files count Total bundle size % Changed
desktop-client 34 13.87 MB 0%
loot-core 1 5.27 MB → 5.27 MB (+553 B) +0.01%
api 2 3.89 MB → 3.89 MB (+537 B) +0.01%
cli 1 7.91 MB 0%
crdt 1 41.83 kB 0%
View detailed bundle stats

desktop-client

Total

Files count Total bundle size % Changed
34 13.87 MB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
static/js/index.js 1.86 MB 0%
static/js/BackgroundImage.js 121.09 kB 0%
static/js/FormulaEditor.js 962.55 kB 0%
static/js/PayeeRuleCountLabel.js 52.52 kB 0%
static/js/ReportRouter.js 1.2 MB 0%
static/js/ScheduleEditForm.js 145.68 kB 0%
static/js/TransactionEdit.js 186.56 kB 0%
static/js/TransactionList.js 85.81 kB 0%
static/js/Value.js 4.94 MB 0%
static/js/ca.js 191.68 kB 0%
static/js/chart-theme.js 796.5 kB 0%
static/js/client.js 451.37 kB 0%
static/js/da.js 104.4 kB 0%
static/js/de.js 174.08 kB 0%
static/js/en-GB.js 8.2 kB 0%
static/js/en.js 176.64 kB 0%
static/js/es.js 181.5 kB 0%
static/js/extends.js 518.66 kB 0%
static/js/fr.js 182.7 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.46 kB 0%
static/js/it.js 168.53 kB 0%
static/js/narrow.js 364.31 kB 0%
static/js/nb-NO.js 151.58 kB 0%
static/js/nl.js 108.66 kB 0%
static/js/pl.js 88.34 kB 0%
static/js/pt-BR.js 193.45 kB 0%
static/js/resize-observer.js 18.06 kB 0%
static/js/th.js 178.91 kB 0%
static/js/theme.js 31.67 kB 0%
static/js/uk.js 212.28 kB 0%
static/js/useFormatList.js 8.63 kB 0%
static/js/wide.js 453 B 0%
static/js/workbox-window.prod.es5.js 7.33 kB 0%
static/js/zh-Hans.js 119.52 kB 0%

loot-core

Total

Files count Total bundle size % Changed
1 5.27 MB → 5.27 MB (+553 B) +0.01%
Changeset
File Δ Size
home/runner/work/actual/actual/packages/loot-core/src/server/transactions/transaction-rules.ts 📈 +553 B (+2.57%) 21.02 kB → 21.56 kB
View detailed bundle breakdown

Added

Asset File Size % Changed
kcab.worker.D2pXlvdi.js 0 B → 5.27 MB (+5.27 MB) -

Removed

Asset File Size % Changed
kcab.worker.JKo6NKKa.js 5.27 MB → 0 B (-5.27 MB) -100%

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged
No assets were unchanged


api

Total

Files count Total bundle size % Changed
2 3.89 MB → 3.89 MB (+537 B) +0.01%
Changeset
File Δ Size
home/runner/work/actual/actual/packages/loot-core/src/server/transactions/transaction-rules.ts 📈 +537 B (+2.56%) 20.52 kB → 21.04 kB
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
index.js 3.89 MB → 3.89 MB (+537 B) +0.01%

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
models.js 0 B 0%

cli

Total

Files count Total bundle size % Changed
1 7.91 MB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
cli.js 7.91 MB 0%

crdt

Total

Files count Total bundle size % Changed
1 41.83 kB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
index.js 41.83 kB 0%

@actual-github-bot actual-github-bot Bot changed the title Fix payee/category is nothing rules not applying correctly [WIP] Fix payee/category is nothing rules not applying correctly Apr 17, 2026
@netlify

netlify Bot commented Apr 17, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit d1d87e2
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget/deploys/69e8fc662df2ec00088516ab
😎 Deploy Preview https://deploy-preview-7531.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hello contributor!

We would love to review your PR! Before we can do that, please make sure:

  • ✅ All CI checks pass
  • ✅ The PR is moved from draft to open (if applicable)
  • ✅ The "[WIP]" prefix is removed from the PR title
  • ✅ All CodeRabbit code review comments are resolved (if you disagree with anything - reply to the bot with your reasoning so we can read through it). The bot will eventually approve the PR.

We do this to reduce the TOIL the core contributor team has to go through for each PR and to allow for speedy reviews and merges.

For more information, please see our Contributing Guide.

@sk10727-a11y sk10727-a11y changed the title [WIP] Fix payee/category is nothing rules not applying correctly Fix payee/category is nothing rules not applying correctly Apr 17, 2026
@netlify

netlify Bot commented Apr 17, 2026

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget-website ready!

Name Link
🔨 Latest commit f3f9f89
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget-website/deploys/69e245c3b07cd800072666af
😎 Deploy Preview https://deploy-preview-7531.www.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 49722165-e116-4eed-bf0d-aa78225860db

📥 Commits

Reviewing files that changed from the base of the PR and between 10c9ba2 and d1d87e2.

📒 Files selected for processing (1)
  • packages/loot-core/src/server/transactions/transaction-rules.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/loot-core/src/server/transactions/transaction-rules.ts

📝 Walkthrough

Walkthrough

Normalize undefined payee/category to null when preparing transactions for rule evaluation, record which fields were normalized on the transaction, and remove those temporary normalizations (and the tracking property) in finalization so the original transaction state is preserved.

Changes

Cohort / File(s) Summary
Transaction Rules Logic
packages/loot-core/src/server/transactions/transaction-rules.ts
prepareTransactionForRules converts undefined payee/category to null and records normalized fields in a new optional _normalizedRuleFields?: string[]; finalizeTransactionForRules deletes properties set to null solely due to normalization and removes _normalizedRuleFields.
Release Notes
upcoming-release-notes/7531.md
Added a Bugfix entry noting that required-field enforcement for "payee is blank" and "category is blank" is now applied correctly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

size small

Poem

🐰 I turned undefined into a tidy null,
Noted each hop in a little tracking lull.
Rules now find blanks that used to hide away,
I twitch my nose and watch them work today. ✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: fixing a bug where rules with 'is nothing' conditions for payee and category were not applying correctly.
Description check ✅ Passed The description is well-detailed and directly related to the changeset, explaining the issue, solution, testing approach, and related issue number.
Linked Issues check ✅ Passed The PR directly addresses issue #5724 by normalizing missing payee/category fields during rule matching, enabling rules with 'is nothing' conditions to match and apply automatically as required.
Out of Scope Changes check ✅ Passed All changes are in-scope: modifications to transaction-rules.ts handle field normalization for rule matching, and the release notes document the fix, both directly addressing the linked issue.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Auto-generated Release Notes

Hey @sk10727-a11y! I've automatically created a release notes file based on CodeRabbit's analysis:

Category: Bugfixes
Summary: Fix payee/category rules to ensure correct application when values are empty.
File: upcoming-release-notes/7531.md

If you're happy with this release note, you can add it to your pull request. If not, you'll need to add your own before a maintainer can review your change.

@netlify

netlify Bot commented Apr 17, 2026

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget-website ready!

Name Link
🔨 Latest commit e3af3ac
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget-website/deploys/69e24602a2f1e90008c7097e
😎 Deploy Preview https://deploy-preview-7531.www.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/loot-core/src/server/transactions/transaction-rules.ts (1)

1043-1065: Add _normalizedRuleFields to TransactionForRules instead of using type assertions.

Per the repo guideline to avoid as assertions, extend the existing TransactionForRules type (line 961) with _normalizedRuleFields?: string[] so the three as TransactionForRules & { _normalizedRuleFields?: string[] } casts in prepare/finalize become plain property access. This also lets finalizeTransactionForRules' subtransaction-cleanup loop (Lines 1129-1143) handle it uniformly alongside balance / _balanceOfPrefetched / parent_amount if ever needed.

♻️ Proposed diff
 export type TransactionForRules = TransactionEntity & {
   payee_name?: string;
   _account?: db.DbAccount;
   balance?: number;
   _category_name?: string;
   _account_name?: string;
   parent_amount?: number;
   /** Prefetched cent balances for BALANCE_OF("…") in rule formulas; cleared in finalize */
   _balanceOfPrefetched?: Map<string, number>;
+  /** Fields normalized from undefined→null for rule matching; cleared in finalize */
+  _normalizedRuleFields?: string[];
 };
@@
-  if (normalizedRuleFields.length > 0) {
-    (
-      r as TransactionForRules & { _normalizedRuleFields?: string[] }
-    )._normalizedRuleFields = normalizedRuleFields;
-  }
+  if (normalizedRuleFields.length > 0) {
+    r._normalizedRuleFields = normalizedRuleFields;
+  }

As per coding guidelines: "Avoid type assertions (as, !) - prefer satisfies for type narrowing".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/loot-core/src/server/transactions/transaction-rules.ts` around lines
1043 - 1065, Extend the TransactionForRules type to include an optional
_normalizedRuleFields?: string[] property and remove the ad-hoc type assertions
in prepareTransactionForRules (and the corresponding casts in
finalizeTransactionForRules), so you can assign r._normalizedRuleFields
directly; update the type definition near TransactionForRules and replace the
three occurrences of "as TransactionForRules & { _normalizedRuleFields?:
string[] }" in prepareTransactionForRules/finalizeTransactionForRules with
direct property access to _normalizedRuleFields to keep handling uniform with
other optional fields like balance/_balanceOfPrefetched/parent_amount.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/loot-core/src/server/transactions/transaction-rules.ts`:
- Around line 1043-1065: Extend the TransactionForRules type to include an
optional _normalizedRuleFields?: string[] property and remove the ad-hoc type
assertions in prepareTransactionForRules (and the corresponding casts in
finalizeTransactionForRules), so you can assign r._normalizedRuleFields
directly; update the type definition near TransactionForRules and replace the
three occurrences of "as TransactionForRules & { _normalizedRuleFields?:
string[] }" in prepareTransactionForRules/finalizeTransactionForRules with
direct property access to _normalizedRuleFields to keep handling uniform with
other optional fields like balance/_balanceOfPrefetched/parent_amount.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cd14d883-d4d2-4153-addc-f1366a1ec24f

📥 Commits

Reviewing files that changed from the base of the PR and between 9956704 and e3af3ac.

📒 Files selected for processing (1)
  • packages/loot-core/src/server/transactions/transaction-rules.ts

coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 17, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 17, 2026
@sk10727-a11y sk10727-a11y changed the title Fix payee/category is nothing rules not applying correctly [WIP] Fix payee/category is nothing rules not applying correctly Apr 17, 2026
@netlify

netlify Bot commented Apr 21, 2026

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget-storybook ready!

Name Link
🔨 Latest commit 6ea8f92
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget-storybook/deploys/69e7dba67fad9d0008464c88
😎 Deploy Preview https://deploy-preview-7531--actualbudget-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 21, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 21, 2026
@sk10727-a11y sk10727-a11y changed the title [WIP] Fix payee/category is nothing rules not applying correctly Fix payee/category is nothing rules not applying correctly Apr 21, 2026
});
}

// remove temporary normalization used for "is nothing" rules

@joel-jeremy joel-jeremy Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of using type assertion. can you do:

if ('__normalizedRuleFields' in trans) {
   // Loop through trans._normalizedRuleFields
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated!

@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions Bot added the Stale label May 27, 2026
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 5 days with no activity.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Rule with payee is "nothing" never matching

2 participants