Programmatically, How does Bitcoin core differentiate transactions category? How does Bitcoin core differentiate transactions category?

for instance, when we are calling listtrnasctions in the response body we have category, how bitcoin core assigns category type for a transaction?
Programmatically, How it decides that some transaction should have send or receive string.  

The answer is in here: 

// Sent
if ((!listSent.empty() || nFee != 0) &amp;&amp; (fAllAccounts || strAccount == strSentAccount))
{

}

// Received
if (listReceived.size() &gt; 0 &amp;&amp; wtx.GetDepthInMainChain() &gt;= nMinDepth)
{


}


Can someone read and explain the code? I see that receive transactions have zero fees, and Bitcoin core considers transactions with fees as sent.
Bitcoin Core has three types of transaction categories: send, receive, and move.

It differentiates between these as follows:


move - This tx is not an onchain one, and has no transaction id. It is simply moving BTC from one wallet account to another (accounts are not addresses, but groupings of addresses). This is done using the move RPC call
send - A send tx is one where an utxo from your wallet is used as the input to a transaction. This usually have a fee, since the fee is debited from the total sum of the utxos.
receive - A receive tx is one where a new utxo spendable (or watched) by your wallet is created. These don't have a fee as you don't pay anything to receive Bitcoin.


You can see the ListTransaction code here.