There's a bug in this code. The if body cannot return after finding the first exceptional transaction.
Only if the transaction is pending approval can it return true, otherwise it must keep looking.

Imagine a working capital that has two exceptional transactions - the first is already approved and the second is pending.
This code will return false, but it should return true.