How to determine if counterclaim compulsory or permissive

If the answer to the following four (4) questions is yes, the counterclaim is compulsory:
  1. Are the issues of fact and law raised by the claim and the counterclaim largely the same? 
  2. Would res judicata bar a subsequent suit on defendant’s claims, absent the compulsory counterclaim rule? 
  3. Will substantially the same evidence support or refute plaintiff’s claim as well as the counterclaim?
  4. Is there any logical relation between the claim and counterclaim?
The above is called the "logical relationship test" which was mentioned in the 2010 case of GSIS v. Heirs of Caballero (G.R. No. 158090). In this case, the Supreme Court held the following:
Tested against the above-mentioned criteria, this Court agrees with the CA's view that petitioner's counterclaim for the recovery of the amount representing rentals collected by Fernando from the CMTC is permissive. The evidence needed by Fernando to cause the annulment of the bid award, deed of absolute sale and TCT is different from that required to establish petitioner's claim for the recovery of rentals. 
The issue in the main action, i.e., the nullity or validity of the bid award, deed of absolute sale and TCT in favor of CMTC, is entirely different from the issue in the counterclaim, i.e., whether petitioner is entitled to receive the CMTC's rent payments over the subject property when petitioner became the owner of the subject property by virtue of the consolidation of ownership of the property in its favor. 
The rule in permissive counterclaims is that for the trial court to acquire jurisdiction, the counterclaimant is bound to pay the prescribed docket fees. This, petitioner did not do, because it asserted that its claim for the collection of rental payments was a compulsory counterclaim. Since petitioner failed to pay the docket fees, the RTC did not acquire jurisdiction over its permissive counterclaim. The judgment rendered by the RTC, insofar as it ordered Fernando to pay petitioner the rentals which he collected from CMTC, is considered null and void. Any decision rendered without jurisdiction is a total nullity and may be struck down at any time, even on appeal before this Court.
There is a logical relationship where conducting separate trials of the respective claims would entail substantial duplication of effort and time and involves many of the same factual and legal issues. In Meliton v. CA (G.R. No. 101883, 1992), the High Court explained the following:
Considering Section 4 of Rule 9 of the Rules of Court, a counterclaim is compulsory if (a) it arises out of, or is necessarily connected with, the transaction or occurrence which is the subject matter of the opposing party's claim; (b) it does not require for its adjudication the presence of third parties of whom the court cannot acquire jurisdiction; and (c) the court has jurisdiction to entertain the claim. 
It has been postulated that while a number of criteria have been advanced for the determination of whether the counterclaim is compulsory or permissive, the "one compelling test of compulsoriness" is the logical relationship between the claim alleged in the complaint and that in the counterclaim, that is, where conducting separate trials of the respective claims of the parties would entail a substantial duplication of effort and time, as where they involve many of the same factual and/or legal issues. 
The phrase "logical relationship" is given meaning by the purpose of the rule which it was designed to implement. Thus, a counterclaim is logically related to the opposing party's claim where, as already stated, separate trials of each of their respective claims would involve a substantial duplication of effort and time by the parties and the courts. Where multiple claims involve many of the same factual issues, or where they are offshoots of the same basic controversy between the parties, fairness and considerations of convenience and of economy require that the counterclaimant be permitted to maintain his cause of action.