If this.currentUser.canActOnBehalfOf( m.senderID ) always returns a boolean, you can do XOR.
return (this.props.mailboxFilter != 'sent') ^ this.currentUser.canActOnBehalfOf(m.senderID);
XOR boolean with true makes NOT. And XOR with false creates a buffer that maintains the same value.
Note that I changed == to != .
And just make sure you add comments to this part of the code if you intend to actually use it. It is not so easy to read this code after a while.
Update
As Bergi, it is recommended to use Boolean XOR != To return a Boolean value.
return (this.props.mailboxFilter != 'sent') != this.currentUser.canActOnBehalfOf(m.senderID);
And of course, if it can be used with Boolean XNOR, just replace both != With == in the code above.
Aᴍɪʀ
source share