Opinion by
Judge CASEBOLT.In this action between attorneys, we must address whether, when multiple separate law firms represent clients under a contingent fee agreement, a withdrawing attorney's claim in quantum meruit against former co-counsel accrues at the time of the withdrawal or at the time that recovery under the contingent fee agreement occurs. We conclude that the claim cannot begin to acerue until the withdrawing attorney knows or should know of the recovery. We therefore reverse the trial court's judgment on the pleadings against plaintiff, The Hannon Law Firm (Hannon), and in favor of defendants, Melat, Pressman & Higbie, LLP. (Melat) and Ho-warth & Smith (Howarth), and remand for further proceedings.
We must also decide whether a withdrawing attorney may assert a claim in quantum meruit against former co-counsel where the withdrawing attorney would be barred by C.R.GC.P. Ch. 28.3, Rule 5(d), from bringing such a claim against the clients. We conclude that Rule 5(d) applies only to claims in quantum meruit brought against a client. We therefore affirm the trial court's order denying Melat's and Howarth's motion to dismiss Hannon's claim.
I. Background
The following facts are taken from Han-non's complaint, which we must construe as true. See Platt v. Aspenwood Condominium Ass'n, 214 P.3d 1060, 1066 (Colo.App.2009).
Melat entered into a contingent fee agreement with certain clients who lived near a uranium mine and initiated tort claims in federal court against the mine owner. Eventually, other law firms, including Hannon, became co-counsel for the clients. With the apparent consent of the clients, those law firms engaged Howarth as lead trial counsel. The firms entered into a fee-sharing agreement, which provided that Howarth would receive forty percent of the total fees obtained in the litigation, and the other three firms would each receive twenty percent. The fee-sharing agreement was silent on the recovery of fees or other compensation if a law firm were to withdraw.
The relationship between Hannon and Ho-warth became strained to the point that Ho-warth "essentially took over the case to the exclusion of [Hannon]." Eventually, Hannon withdrew, with court approval, from representation in the case. At the time of its withdrawal, Hannon lawyers had worked 541.4 hours and Hannon paralegals had worked 1881.9 hours on the case. Hannon had also incurred over $160,000 in costs.
After multiple trials and appeals, the federal case settled, and the clients paid to *58Howarth and Melat the fees and costs called for under the contingent fee agreement. At that time, Melat paid Hannon for the costs Hannon had incurred before withdrawal, but refused to pay any compensation for the services that Hannon had rendered.
A little less than three years after being notified of the settlement, Hannon filed the complaint in this action, asserting a single claim for quantum meruit against Melat and Howarth for the reasonable value of the services it had provided before withdrawal. Melat and Howarth moved to dismiss the complaint for failure to state a claim upon which relief could be granted under C.R.C.P. 12(b)(5), contending that, because C.R.C.P. Ch. 28.3, Rule 5(d) would prevent Hannon's recovery of any fees from the client in quantum meruit, Hannon could not recover from Melat and Howarth. Concluding that Han-non had presented a viable theory of recovery, the trial court denied the motion.
Melat and Howarth then moved for judgment on the pleadings, asserting that the statute of limitations had run before Hannon commenced this action because the quantum meruit claim accrued, at the latest, when Hannon withdrew from representation of the clients. Hannon responded that the quantum meruit claim did not accrue until recovery occurred in the underlying case, and that it had commenced this action within the three-year period from that date. Conelud-ing that it needed to consider an exhibit attached to Hannon's complaint to determine the issue, the trial court treated the motion as one for summary judgment and determined that the claim accrued at the time Hannon provided the services and withdrew from representation. Accordingly, it granted the motion, and this appeal followed.
II Acerual of Quantum Meruit Claim
Hannon contends that the trial court erred in granting judgment on the pleadings because the quantum meruit claim could not accrue, for statute of limitations purposes, until at least the time Hannon learned or should have learned of the recovery under the contingent fee agreement. We agree.
A. Standard of Review
In considering a motion for judgment on the pleadings, the trial court must construe the allegations of the pleadings strictly against the movant, must consider the allegations of the opposing party's pleadings as true, and should not grant the motion unless the pleadings themselves show that the matter can be determined on the pleadings. Platt, 214 P.3d at 1066. Entry of judgment on the pleadings is proper only if the material facts are undisputed and the movant is entitled to judgment as a matter of law. Id. We review de novo an order entering judgment on the pleadings, id., employing the same standards as the trial court.
B. Law
The statute of limitations applicable to a quantum meruit claim is three years from the date the claim accrues. § 13-80-101(1)(a), C.R.S.2010; Rotenberg v. Richards, 899 P.2d 365, 368 (Colo.App.1995). A cause of action generally accrues "when a suit may be maintained thereon." Jones v. Cox, 828 P.2d 218, 224 (Colo.1992).
Quantum meruit "is a theory of contract recovery that invokes an implied contract when the parties either have no express contract or have abrogated it." Dudding v. Norton Frickey & Assocs., 11 P.3d 441, 444 (Colo.2000). Section 183-80-108(6), C.R.S.2010, provides that a cause of action for "breach of any express or implied contract" accrues "on the date the breach is discovered or should have been discovered by the exercise of reasonable diligence." A claim in quantum meruit therefore accrues when a person discovers, or through the exercise of reasonable diligence should discover, that all elements of the claim are present. See Estate of Draper v. Bank of Am., 288 Kan. 510, 205 P.3d 698, 715 (2009); see also Jones, 828 P.2d at 224.
To recover in quantum meruit, a plaintiff must demonstrate that (1) at the plaintiff's expense; (2) the defendant received a benefit; (8) under cireumstances that would make it unjust for the defendant to retain the benefit without paying for it. Dudding, 11 P.3d at 445. The statute of *59limitations therefore begins to run with respect to a quantum meruit claim when a plaintiff has conferred a benefit upon the defendant and the retention of the benefit becomes unjust. See Draper, 205 P.3d at 715 (citing Vila v. Inter-Am. Inv., Corp., 536 F.Supp.2d 41, 51 (D.D.C.2008), aff'd, 570 F.3d 274, 284-85 (D.C.Cir.2009)).
There are no Colorado cases determining when the benefit of an attorney's services rendered pursuant to a contingent fee agreement and a fee sharing agreement becomes unjust so as to mark an acerual of the claim. We accordingly look to analogous cases to assist us.
In determining whether retention of the benefit is unjust, the supreme court has identified various fact-specific tests that apply in particular situations. See Lewis v. Lewis, 189 P.3d 1134, 1143 (Colo.2008) (where gifts or contracts between close family members fail, retention of benefit becomes unjust where one undertakes an action that is a significant deviation from mutual purpose); DCB Constr. Co. v. Central City Dev. Co., 965 P.2d 115, 122 (Colo.1998) (where contractor confers benefit on landlord for work done on behalf of tenant, landlord must engage in some type of malfeasance in order for retention of benefit to become unjust). In the absence of a particularized test, we conclude we should analyze the intentions, expectations, and behavior of the parties to determine when retention of the benefit becomes unjust. Lewis, 189 P.3d at 1143 (citing Coblevision of Breckenridge, Inc. v. Tannhauser Condo. Ass'n, 649 P.2d 1093, 1098 (Colo.1982)); see also 26 Richard A. Lord, Willston on Contracts § 68:1, at 24 (4th ed.2003) (courts generally allow recovery in quantum meruit "when a party confers a benefit with a reasonable expectation of payment").
C. Application
We first address the trial court's conversion of the motion for judgment on the pleadings to a motion for summary judgment and then address the trial court's determination of the acerual date for Hannon's quantum meruit claim.
1. Judgment on the Pleadings or Summary Judgment
We note initially that the trial court converted the motion for judgment on the pleadings to a motion for summary judgment because it concluded that it needed to review the exhibit attached to Hannon's complaint, which it construed to be outside the pleadings. Such a conclusion was unnecessary, however, because a document that is referred to in or is attached to a complaint may be reviewed by the court on a motion for judgment on the pleadings without converting the motion to one for summary judgment. See Yadon v. Lowry, 126 P.3d 332, 335 (Colo.App.2005) (upon considering a C.R.C.P. 12(b)(5) motion, a court may consider a document referred to in, but not attached the complaint, without converting the motion to dismiss into a motion for summary judgment). However, because we review de novo and treat the motion as one for judgment on the pleadings, any error by the trial court is harmless here.
2. Time of Accrual
The trial court held, and the parties do not dispute, that the first two elements of the claim were present when Hannon ceased providing legal services and withdrew from the case. We agree that, based on the complaint, at Hannon's expense, Melat and Ho-warth received a benefit.
The trial court further determined that
while it is true that the benefit of [Han-non's] services may have continued beyond the date when it was originally given, the benefit of that work was certainly received by [Melat and Howarth] at the time the services were initially rendered. As such, the value of the ... services was owed at the time the last work was performed.
It accordingly concluded that Hannon's claim accrued, at the latest, on the last day Hannon provided services, which occurred almost nine years before it filed this action. We disagree with this conclusion, because it focuses on the time the benefit was conferred, and fails to analyze when the retention of the benefit became unjust.
*60We first turn to the accrual standard found in section 183-80-108(6), which states that a claim for breach of an implied contract acerues when the plaintiff discovers or should discover the breach. Read literally, this language does not provide any guidance because "breach" is not an element of a quantum meruit claim. Unlike a contract claim, a claim in quantum meruit requires no proof of any agreement or breach. Rather, quantum meruit is described as a "theory of contract recovery that invokes an implied contract," meaning that a court implies a contractual relationship where the elements of quantum meruit are present. See Dudding, 11 P.3d at 444.
The parties urge us to adopt one of two rules, termed the California rule and the New York rule, regarding the time of accrual governing an attorney's quantum meruit claim for legal services provided pursuant to a failed contingent fee agreement. The California rule holds that an attorney's claim accrues when the contingency occurs. See Fracasse v. Brent, 6 Cal.3d 784, 792, 100 Cal.Rptr. 385, 494 P.2d 9, 14 (1972). The New York rule holds that the claim accrues when the attorney withdraws. See Tillman v. Komar, 259 N.Y. 133, 181 N.E. 75, 76 (1932). But these rules were formulated to determine when an attorney's quantum me-ruit claim against a client accrues, not when an attorney's claim against another attorney acerues. The reasoning supporting the rules is therefore primarily centered on policy considerations unique to the attorney-client relationship.
For example, the Fracasse court reasoned that the New York rule can lead to "grossly unfair consequences" where the client would have to pay the attorney more than his claim might be worth. 6 Cal.3d at 787, 100 Cal.Rptr. 385, 494 P.2d at 11. It also reasoned that the New York rule could interfere with a client's ability to discharge the attorney at any time with or without cause, an important aspect of the attorney-client relationship. Id. at 789-90, 100 Cal.Rptr. 385, 494 P.2d at 12-13. These policy considerations do not apply to an attorney's claim in quantum me-ruit against another attorney that arises outside a failed fee sharing agreement.
We therefore decline to adopt the reasoning of either rule. Instead, we analyze when the retention of the legal services rendered by Hannon became unjust with reference to the intentions, expectations, and behavior of the parties to the failed fee sharing agreement. See Lewis, 189 P.3d at 1143; Cablevision, 649 P.2d at 1098.
Here, there is no question that Hannon, Melat, and Howarth intended and knew that they would receive compensation if, but only if, the contingency came to fruition. The parties were therefore aware of the possibility that they would receive no compensation at all for their legal services if there were no recovery in the underlying litigation. Given these intentions and expectations, an attorney's retention of the benefit of legal services provided by a withdrawing attorney cannot be unjust if no recovery ever occurs in the underlying litigation. The withdrawing attorney, at the time the benefit is conferred on the other attorneys, expects that he or she will not receive any compensation if the contingency does not occur. It therefore could not be unjust for the remaining attorneys to retain the benefit conferred without paying for it if the contingency never comes to fruition.
Moreover, this conclusion is consistent with the behavior of the parties. Melat and Howarth did not and do not contend that Hannon was not entitled to be paid for the costs it had expended before withdrawal. Indeed, they paid Hannon for the costs it had incurred after the settlement of the underlying claim, implying they recognized that retention of Hannon's incurred costs would be unjust after they had recouped those costs from the clients as a result of the realization of the contingency.
Melat and Howarth nevertheless point out that Hannon's complaint alleges that Ho-warth engaged in wrongful conduct that made it difficult for Hannon to continue its duties to the clients and that Hannon cited such conduct as its justification for withdrawing. Accordingly, they reason that the retention of the benefit became unjust at the time of Hannon's withdrawal. But this conclusion places too much emphasis on "wrongdoing" by the parties and too little emphasis *61on their intentions and expectations. See Lewis, 189 P.3d at 1142 (malfeasance not required in all civreumstances for enrichment to be unjust).
We recognize that whether an attorney withdraws for good cause may be an important consideration in determining, on the merits, whether the retention of the benefit of legal services is unjust. See Jenkins v. District Court, 676 P.2d 1201, 1204 (Colo.1984) (an attorney who withdraws for good cause or is terminated by a client without cause may recover from the client in quantum meruit); of Restatement (Third) of the Law Governing Lawyers § 40 emt. e (2000) (an attorney who withdraws without good cause forfeits the right to compensation for his services). But a determination of whether withdrawal is supported by good cause is not a proper inquiry in determining when a claim accrues. Instead, it relates to a merits determination.
Moreover, even if an attorney has good cause to withdraw, it would still not be unjust for, any remaining attorneys to retain the benefit of the withdrawing attorney's legal services where no recovery occurs in the underlying litigation. Therefore, whether the attorney had good cause to withdraw may affect the attorney's ultimate ability to recover on the merits, but it is not determinative in deciding when a claim acerues. The claim can only accrue, if it accrues at all, when recovery occurs in the underlying litigation.
Melat and Howarth also contend that the rule we announce improperly makes quantum meruit recovery dependent upon a failed contract which no longer governs the relationship between the parties. See Tillman, 181 N.E. at 75 (holding that a contingent fee agreement between an attorney and a client either "wholly stands or totally falls," and after cancellation, its terms no longer establish the sole standard for attorney compensation); see also Dudding, 11 P.3d at 444 (quantum meruit recovery "does not depend upon the existence of a contract"). It is true that a claim in quantum meruit "exist[s] independently of a contract" and therefore does not necessarily turn on the terms of a failed contract between the parties Dudding, 11 P.3d at 445. But the failed contract in this case is the fee sharing agreement, not the contingent fee agreement that remained in force and was fully performed. We therefore are not relying on the terms of the failed fee sharing agreement when determining the time for accrual of Hannon's claim in quantum meruit.
In addition, we have found no authority indicating that an existing contractual relationship between some parties cannot inform the expectations of other parties for purposes of assessing a claim in quantum meruit. To the contrary, in Cablevision, the court held that because the cable service provided to the defendants in that case was "customarily paid for," it was clear that the cable service provider expected compensation for the service and that the defendants knew of that expectation. Cablevision, 649 P.2d at 1098. The court therefore determined that other contracts with other subscribers informed the expectations of the parties involved in the relevant dealings. See id.
Similarly, in the present case, all the law firms knew that work provided in the underlying litigation was subject to a contingent fee agreement and they therefore expected compensation for their services only if recovery occurred.
Melat and Howarth point out that Hannon filed an attorney's lien in the underlying litigation, indicating that compensation was due at the time of withdrawal. However, it could be equally inferred that Hannon expected payment only when the underlying claim was favorably resolved. See § 12-5-119, C.R.S.2010 (attorney has lien on any choses in action or claims and demands in suit for any fees due or to become due from any client); Platt, 214 P.3d at 1066 (in considering a motion for judgment on the pleadings, court must construe the allegations of the pleadings strictly against the movant). Accordingly, the lien filing is not determinative.
Melat and Howarth alternatively urge us to hold that the claim accrues upon withdrawal because such a rule would require a withdrawing attorney to file suit promptly, thus decreasing the risk that evidence would *62be lost or destroyed or that witnesses would become unavailable. Hence, the argument proceeds, accrual upon withdrawal would better effectuate the purposes of the statute of limitations. See Lake Canal Reservoir Co. v. Beethe, 227 P.3d 882, 886 (Colo.2010) (statutes of limitation should be construed to "promote justice, discourage unnecessary delay and forestall prosecution of stale claims" (quoting Jones, 828 P.2d at 224)). But the rule Melat and Howarth urge us to adopt would make it difficult for a trial court to determine whether and how much should be awarded prior to recovery of the contingent fee. See Law Offices of J.E. Losavio, Jr. v. Law Firm of Michael McDivitt, P.C., 865 P.2d 934, 936 (Colo.App.1993) (delineating the factors that a court should use in determining a quantum meruit award as between attorneys, including amount involved, the result obtained, and whether the fee is fixed or contingent). In some cases, a withdrawing attorney might receive more in quantum me-ruit compensation than the remaining attorneys collect upon completing work in the case. In other cases, a withdrawing attorney might receive little, if anything, because of difficulty in proving the value of the services provided. While it is true that a party could request a stay of the proceedings until resolution of the underlying litigation if accrual were to occur upon withdrawal, we fail to see how this rule better effectuates the purposes of the statute of limitations, given that under either rule, the claim would likely not be resolvable before the disposition of the underlying litigation.
We therefore conclude that a withdrawing attorney's claim in quantum me-ruit against former co-counsel laboring under a contingent fee agreement cannot accrue earlier than the time when recovery occurs in the underlying litigation, because that is the earliest time when the unjustness of any retention of the benefit can be determined. Accordingly, Hannon's claim accrued when it knew or should have known of the recovery.
Based on the allegations of Hannon's complaint, that knowledge was gained on September 29, 2004, when Melat informed it of the settlement. Accordingly, this action, commenced on September 26, 2007, was filed within the three-year statute of limitations applicable to quantum meruit claims and, thus, it is not barred by the statute of limitations. Hence, the trial court erred in entering judgment on the pleadings in favor of Melat and Howarth.
III. Recovery Precluded by Contingent Fee Rules?
Melat and Howarth urge us to employ an alternate ground to uphold the judgment by determining that the trial court erred in denying their motion to dismiss Hannon's complaint for failure to state a claim under C.R.C.P. 12(b)(5). Specifically, Melat and Howarth contend that Hannon's claim against them cannot succeed because a similar claim against the client in this case would be barred by C.R.C.P. Chapter 28.3, Rule 5(d). We disagree.
A. Standard of Review
The purpose of a motion under C.R.C.P. 12(b)(5) is to test the legal sufficiency of the complaint to determine whether the plaintiff has asserted a claim or claims upon which relief can be granted. Hemmann Mgt. Servs. v. Mediacell, Inc., 176 P.3d 856, 858-59 (Colo.App.2007). In evaluating a motion to dismiss under C.R.C.P. 12(b)(5), the court must accept as true all averments of material fact and must view the allegations of the complaint in the light most favorable to the plaintiff. Id. Courts view CRCP. 12(b)(5) motions to dismiss with disfavor; such motions should not be granted "unless it appears beyond doubt that the plaintiff can prove no set of facts in support of his claim which would entitle him to relief." Dunlap v. Colo. Springs Cablevision, Inc., 829 P.2d 1286, 1291 (Colo.1992) (quoting Davidson v. Dill, 180 Colo. 123, 131-32, 503 P.2d 157, 162 (1972).
"In most cases it is sufficient if the pleader clearly identifies the transactions which form the basis of the claim for relief, and if upon any theory of the law relief is warranted by the evidence offered and received in support of the claim.. .." Hinsey v. Jones, 159 Colo. 326, 329, 411 P.2d 242, 244 (1966) (quoting Weick v. Rickenbaugh Cad*63illac Co., 134 Colo. 283, 289, 303 P.2d 685, 688 (1956)).
Because it presents a question of law, we review de novo an order granting or denying a motion to dismiss under C.R.C.P. 12(b)(5). See Dotson v. Bernstein, 207 P.3d 911, 912 (Colo.App.2009).
B. Law
Generally, an attorney may recover under a quantum meruit theory for the reasonable value of legal services provided, as long as the elements of the claim are proved. Mullens v. Hansel-Henderson, 65 P.3d 992, 995 (Colo.2002). However, C.R.C.P. Chapter 23.3, which sets forth rules governing contingent fee arrangements, limits such recovery in certain situations. Elliott v. Joyce, 889 P.2d 43, 46 (Colo.1994). An attorney who withdraws during representation on a contingent fee basis may recover in quantum meruit from a client only if the agreement explicitly states that such a recovery is possible. Id. (analyzing C.R.C.P. Ch. 23.8, Rule 5(d)). This notice requirement assures that the client knows upon entering into the agreement whether he or she will be liable for attorney fees at any time other than the occurrence of the contingency. Mullens, 65 P.3d at 998.
However, a claim in quantum meruit that does not require a client to pay an attorney at a time other than occurrence of the contin-geney is not barred by Chapter 28.3. See Mullens, 65 P.3d at 999 (holding an attorney's claim in quantum meruit not barred by Chapter 28.3 where he had completed the contemplated legal services because client had notice that she must pay upon occurrence of the contingency).
C. Analysis
Here, assuming that the contingent fee agreement referenced in Hannon's complaint does not sufficiently notify the client of the possibility of a recovery in quantum meruit, Hannon would be barred from such recovery against the clients by Chapter 28.3, Rule 5(d). Elliott, 889 P.2d at 46. But even if that is true, we do not perceive that the rule would bar Hannon's claim in quantum meruit against former co-counsel. The basic rule is that an attorney is entitled to compensation in quantum meruit assuming that the attorney can prove the elements of the claim See Losavio, 865 P.2d at 936 (attorney may recover in quantum meruit against another attorney when services are rendered to a common client under a contingency agreement).
In this case, Hannon's claim against Melat and Howarth does not request or require the client to pay any money other than what was contemplated in the contingent fee agreement. We therefore conclude that no requirement to give notice to the client under Chapter 23.8 is relevant to this situation and Hannon's claim is not barred.
Melat and Howarth assert that the rule we adopt allows for the disparate result that an attorney working alone for a client cannot recover in quantum meruit where the contingent fee agreement is silent on the possibility of such recovery, but that an attorney working with other attorneys can recover. They contend that this result is illogical and therefore not what Chapter 28.3 intends. But this contention misperceives the intention of the rules in Chapter 28.8, which is protecting clients, not preventing attorneys from receiving compensation.
Here, Hannon's claim requires the client to pay nothing aside from the contingent fee contemplated in the agreement. The disparate results for attorneys in the two situations discussed above are logically related to the goal of protecting clients and are a necessary consequence of the intended rule.
We therefore conclude that the trial court did not err by denying the motion to dismiss.
The judgment on the pleadings is reversed, the order denying the motion to dismiss is affirmed, and the case is remanded for further proceedings consistent with this opinion.
Judge FURMAN concurs. Judge TERRY dissents.