We have for review an order denying a petition for writ of mandamus, in which appellant alleged that one of two consecutive sentences imposed in 1982 had expired by the time he was released on parole. The mandamus petition alleged that the Department of Corrections (DOC) erroneously forfeited gain time earned on the expired sentence upon revocation of his parole, illegally extending the time he had yet to serve. See Orosz v. Singletary, 693 So.2d 538, 539 (Fla.1997) (holding that a prisoner, “who has fully completed a sentence because of gain time awarded under a proper interpretation of the statutes applicable to his sentences, has a vested right in that gain time”); Morton v. Fla. Dep’t of Corr., 957 So.2d 667, 669 (Fla. 1st DCA 2007) (“Since petitioner had finished serving his first sentence and was serving his second sentence when he was released on parole, the subsequent revocation of petitioner’s parole permitted the Department to forfeit only the basic gain-time awarded on the second sentence.”).
Proceedings below began October 31, 2012, when appellant filed a petition for writ of mandamus in the Second Circuit. In response to an order to show cause why relief should not be granted, the DOC filed a motion to dismiss on grounds of res judicata, attaching a habeas petition previously filed by appellant in the Fifth Circuit on November 21, 2011, and an order denying the habeas petition entered on December 12, 2011. The habeas petition alleged that the DOC forfeited gain time from an expired sentence. Appellant argues that it was improper for the DOC to raise the defense of res judicata in a motion to dismiss and that, even if properly raised, res judicata should not bar consideration of his mandamus petition, because his ha-beas petition was not adjudicated on the merits by the Fifth Circuit.
Under the doctrine of res judica-ta, a subsequent action is barred if there is (1) identity of the thing sued for, (2) identity in the cause of action, (3) identity of persons and parties to the actions, and (4) identity of the quality or capacity of the person for or against whom the claim is made. See Weaver v. McNeil, 42 So.3d 805, 805-06 (Fla. 1st DCA 2010). “[R]es judicata bars relitigation in a subsequent cause of action not only of claims raised,but also [of] claims that could have been raised.” Topps v. State, 865 So.2d 1253, 1255 (Fla.2004). However, “for a matter to have res judicata ejfect, the disposition of a writ petition must be on the merits.” Id. at 1256 (emphasis in original).
Denying the habeas petition as the Fifth Circuit did is consistent with the Fifth Circuit’s failing to reach appellant’s contention under Orosz on the merits. Although appellant’s prior habeas petition sought his immediate release, it did not allege the expiration of both sentences under which appellant was originally incarcerated. This omission would have justified the Fifth Circuit’s denial of habeas relief without reaching the merits of the claim he makes in the present case. The Fifth Circuit might have dismissed the ha-beas petition with leave to file a mandamus petition, or simply transferred the petition to the Second Circuit for adjudication as a mandamus petition. Cf. Stanley v. Moore, 744 So.2d 1160, 1161 (Fla. 1st DCA 1999) (reversing the dismissal of a mandamus petition and remanding with directions for the circuit court to treat the petition as a habeas petition and transfer it to the appropriate court). All along, the proper vehicle for appellant’s claim has been a petition for writ of mandamus. See Bush v. State, 945 So.2d 1207, 1210 (Fla.2006); see also Stanley, 744 So.2d at 1161 (stating that a petition alleging facts which would *394arguably entitle the petitioner to immediate release was a habeas petition).
Pretermitting the question of whether the DOC raised res judicata in a manner permitted by the Florida Rules of Civil Procedure, the wording of the Fifth Circuit’s decision does not establish that appellant’s claim was adjudicated on the merits. The Fifth Circuit’s order denying habeas relief, apparently without an evi-dentiary hearing, provided, in part:
General allegations are insufficient to demonstrate entitlement to relief.
3. Gain time and release are revoked for an Inmate who violates a condition of release prior to the expiration of their full, pronounced prison term, and the Inmate may be reincarcerated for the balance of their term. In order to restore gain time, the Inmate’s sole remedy is through the administrative grievance process. [A] trial court lacks authority to direct Department of Corrections (DOC) to award administrative gain time or provisional credits. The authority to regulate gain time resides with the Department of Corrections.
4.. In this case, Petitioner has failed to show probable cause that he is being illegally detained. As noted above, a trial court lacks authority to direct the Department of Corrections to award administrative gain time or provisional credits.
[[Image here]]
[T]he Petitioner’s Emergency Application for Writ of Habeas Corpus is DENIED.
(internal citations and boldface omitted). A fair reading of the foregoing is that no basis on which the Fifth Circuit acted necessarily entailed an adjudication of the merits of appellant’s claim. See also Thomson McKinnon Sec., Inc. v. Slater, 615 So.2d 781, 788 (Fla. 1st DCA 1993) (noting that the supreme court has held that the “doctrine [of res judicata] is not applicable to a judgment which might have rested on either of two grounds, only one of which goes to the merits”).
As a general matter, we have no quarrel with the proposition that restating a habe-as claim, which has been denied on the merits, as a mandamus claim should not insulate the claim from issue preclusion in appropriate circumstances. In the present case, however, it is by no means clear that appellant’s petition for writ of habeas corpus was adjudicated on the merits when the Fifth Circuit denied it. Accordingly, we reverse and remand for further proceedings, and an adjudication on the merits. As to the merits of appellant’s claims, we express no view. Their resolution may depend on the order in which appellant’s consecutive sentences were required to be served when pronounced. Neither the sentencing transcript nor the written sentence is part of the record on appeal.
Reversed and remanded.
WOLF and MAKAR, JJ., concur.