Repository: paperless-ngx/paperless-ngx

Issue:
[BUG] E-Mail-Filter matching on non-Emails
### Description

I am using an Email-Rule to receive invoices. Two different for two different users.
To assign them to an user, I add a workflow that uses the E-Mail-Rule-Filter and then assigns the owner and  the storage location.
For whatever reason this is applying on every scanned document (which is consumed via consumption folder).

The Mail Rule:

![image](https://github.com/paperless-ngx/paperless-ngx/assets/12600527/b7f095d7-36e4-409a-88e1-f96ccd5911f0)


The Workflow:

![Bildschirmfoto vom 2024-04-23 12-11-10](https://github.com/paperless-ngx/paperless-ngx/assets/12600527/8abb9ad1-7d82-4379-a8ec-a8e11138668c)


### Steps to reproduce

1. Add a mail rule to collect a document from mail
2. Add a workflow which is filtering the mail rule from stepp 1.
3. Add a document to the consumption folder.



### Webserver logs

```bash
...
[2024-04-20 11:05:11,431] [INFO] [paperless.management.consumer] Adding /usr/src/paperless/consume/20240420_100319.pdf to the task queue.

[2024-04-20 11:05:12,235] [DEBUG] [paperless.tasks] Skipping plugin CollatePlugin

[2024-04-20 11:05:12,236] [DEBUG] [paperless.tasks] Skipping plugin BarcodePlugin

[2024-04-20 11:05:12,236] [DEBUG] [paperless.tasks] Executing plugin WorkflowTriggerPlugin

[2024-04-20 11:05:13,475] [INFO] [paperless.matching] Document matched WorkflowTrigger 6 from Workflow: Pauschal zu Finkman

[2024-04-20 11:05:13,678] [INFO] [paperless.matching] Document did not match Workflow: Tag Kontoauszug

[2024-04-20 11:05:13,678] [DEBUG] [paperless.matching] ('Document path /usr/src/paperless/consume/20240420_100319.pdf does not match Sven/Kontoauszug/*',)

[2024-04-20 11:05:13,686] [INFO] [paperless.matching] Document did not match Workflow: Lohnabrechnung

[2024-04-20 11:05:13,686] [DEBUG] [paperless.matching] ('Document path /usr/src/paperless/consume/20240420_100319.pdf does not match Sven/Lohnabrechnung/*',)

[2024-04-20 11:05:13,693] [INFO] [paperless.matching] Document did not match Workflow: Karo Import

[2024-04-20 11:05:13,694] [DEBUG] [paperless.matching] ('Document path /usr/src/paperless/consume/20240420_100319.pdf does not match */Karo/*',)

[2024-04-20 11:05:13,698] [INFO] [paperless.matching] Document did not match Workflow: Kinder zu alle

[2024-04-20 11:05:13,699] [DEBUG] [paperless.matching] No matching triggers with type 1 found

[2024-04-20 11:05:13,703] [INFO] [paperless.matching] Document did not match Workflow: Landstuhl zu ImmoGbr

[2024-04-20 11:05:13,704] [DEBUG] [paperless.matching] No matching triggers with type 1 found

[2024-04-20 11:05:13,710] [INFO] [paperless.matching] Document matched WorkflowTrigger 7 from Workflow: Karo Email Import zu Karo Speicherordner

[2024-04-20 11:05:13,730] [INFO] [paperless.tasks] WorkflowTriggerPlugin completed with: Applying WorkflowAction 6 from Workflow: Pauschal zu Finkman

Applying WorkflowAction 7 from Workflow: Karo Email Import zu Karo Speicherordner

[2024-04-20 11:05:14,030] [INFO] [paperless.consumer] Consuming 20240420_100319.pdf
...
```


### Browser logs

_No response_

### Paperless-ngx version

2.7.2

### Host OS

Synology

### Installation method

Docker - official image

### Browser

Safari

### Configuration changes

_No response_

### Other

_No response_

### Please confirm the following

- [X] I believe this issue is a bug that affects all users of Paperless-ngx, not something specific to my installation.
- [X] I have already searched for relevant existing issues and discussions before opening this report.
- [X] I have updated the title field above with a concise description.


Discussion:

Resolving patch:
diff --git a/src/documents/matching.py b/src/documents/matching.py
--- a/src/documents/matching.py
+++ b/src/documents/matching.py
@@ -269,8 +269,7 @@ def consumable_document_matches_workflow(
 
     # Document mail rule vs trigger mail rule
     if (
-        document.mailrule_id is not None
-        and trigger.filter_mailrule is not None
+        trigger.filter_mailrule is not None
         and document.mailrule_id != trigger.filter_mailrule.pk
     ):
         reason = (


Test patch: