To make the code self-documenting and easier to test, I'd suggest extracting this filter to a method (for which you can write a test).