Returning TRUE from a views_php filter does not work as expected


I have written a Global PHP filter, in a View, and I am expecting the returned value to be TRUE when a condition is met and when TRUE it should eliminate that row from my result set. The view displays its results in a table.

The filter code I have is as follows

global $user;
$uid = $user->uid;
$bid = db_query("SELECT entity_id FROM {field_data_field_bid_request_reference} WHERE field_bid_request_reference_line_item_id = '$row->line_item_id'");
foreach($bid as $value) {
    $node_uid = db_query("SELECT uid FROM {node} WHERE nid = '$value->entity_id'")->fetchField();
    if( $node_uid != $uid) {
       return TRUE;

I am getting the results I expect as far as the if statement. The $node_uid is returning exactly want I want, the uid for whoever created the node with the nid = to the entity_id obtained from the db_query.

In my testing I have 12 rows, each with a line_item_id. There are 6 possible results for $node_uid and I am seeing them if I use a drupal_set_message to look at the 4 node_id inside the foreach. In my test case I have a uid of 5 and this should match 3 times. I should only see 3 rows in my final results.

The problem is that the 9 rows that should be eliminated because they match the if statement and should return TRUE are actually the rows displayed and the 3 that should fail the if statement test and should be displayed are the ones being removed from the output. This is almost as if the return value is reversed.

What ever I do it is as if the return value is incorrect when the if statement passes.

I would have expected the cases where the node_id to not equal the uid to return TRUE and these lines to not appear in my table.

Can anyone offer any suggestions about what could be going wrong and also about how to debug this filter?

When the filter displays TRUE, it filters out, AFAIK. So, you should probably have

if ($node_uid == $uid) {
  return TRUE;