
870 A.2d 58 (2005)
JORDAN KEYS & JESSAMY, LLP, Appellant,
v.
ST. PAUL FIRE AND MARINE INSURANCE COMPANY, Appellee.
No. 03-CV-1380.
District of Columbia Court of Appeals.
Argued January 19, 2005.
Decided March 3, 2005.
*59 Kathleen A. Carey for appellant.
John J. Hathway for appellee.
Before SCHWELB and RUIZ, Associate Judges, and BELSON, Senior Judge.
SCHWELB, Associate Judge:
The question presented in this case is whether an insurance carrier (St. Paul Fire and Marine Insurance Company, hereinafter St. Paul or the carrier) is obligated to pay the plaintiff law firm (Jordan Keys & Jessamy, LLP, hereinafter Jordan Keys) for legal services performed by Jordan Keys on behalf of St. Paul's insured, Greater Southeast Community Hospital (the Hospital) in a medical malpractice suit. Although no express contract existed between Jordan Keys and St. Paul, Jordan Keys claimed in the trial court, and continues to contend on appeal, that it is entitled to recover on a theory that there was an "implied-in-fact" contract between the parties. In the alternative, Jordan Keys asserts that St. Paul has been unjustly enriched and that Jordan Keys has a right to recover in quantum meruit on a quasi contract theory.[1]
The trial court dismissed Jordan Keys' complaint, as amended, for failure to state a claim upon which relief may be granted. We affirm.


*60 I.

THE AMENDED COMPLAINT
In its amended complaint, Jordan Keys alleged that the firm was retained by the Hospital to defend it in an action for medical malpractice based on brain injuries said to have been suffered by Kharee Thompson, the minor child of Steven A. Thompson and Tonya Thompson. Jordan Keys further alleged that it provided services to the Hospital, which included
numerous [c]ourt appearances, engaging in lengthy, complicated discovery, identifying and interviewing medical experts, defending the matter through mediation, and expending over three hundred attorney and paralegal hours. In addition, plaintiff incurred expenses on [the Hospital's] behalf in preparing the case for trial. Plaintiff did not receive full payment for services rendered and expenses paid.
At the time Jordan Keys provided its services, the Hospital was self-insured for the first $1,000,000 of liability. St. Paul provided excess coverage with a policy limit of $4,000,000. Jordan Keys acknowledges that, under its retainer agreement, its fees were to be paid by the Hospital, not by the carrier. According to Jordan Keys, however, St. Paul directed and controlled the litigation, and required Jordan Keys to provide regular status reports, evaluations, and summaries of depositions, dispositive motions, and court proceedings. St. Paul required these reports because, in the event that Mr. and Mrs. Thompson were awarded more than $1,000,000, the carrier, through its "excess coverage" policy, would be required to pay any amount above $1,000,000, up to the $4,000,000 limit.
On May 27, 1999, the Hospital filed a petition for bankruptcy protection. As a result, the Thompsons' malpractice action against the Hospital was stayed by order of the Bankruptcy Court. According to Jordan Keys, the Hospital owed the law firm in excess of $67,000 in unpaid legal fees and costs.
In the spring of 2001, the plaintiffs in the Thompson case agreed to proceed solely against St. Paul's $4,000,000 excess insurance policy, and not to seek recovery from the Hospital for the first $1,000,000 in liability, for which the Hospital was self-insured. Based on that agreement, the Bankruptcy Court lifted the stay of the Thompson litigation. The Hospital then tendered its defense to its carrier. Upon taking charge of the litigation, St. Paul elected to replace Jordan Keys as defense counsel in the suit by the Thompsons.
The events that allegedly followed are described in paragraphs 17-20 of the amended complaint:
17. Defendant [St. Paul] directed plaintiff [Jordan Keys] to provide its legal files, including documents privileged as attorney work product, to the new law firm in order that such firm might prepare for the pretrial conference and defend the suit at trial. Plaintiff asserted a lien on the client files and refused to forward its work product to the newly-retained law firm without having its legal bill satisfied by Defendant, who intended to and did ultimately rely upon plaintiff's work product in defense of the litigation to its own benefit, i.e., to protect its policy of excess insurance.
18. In the face of plaintiff law firm's refusal to follow Defendant's instructions and surrender all files, [the Hospital] then successfully petitioned the Bankruptcy Court to order plaintiff law firm to release the files to [the Hospital] and turn over non-work product documents *61 to new counsel for [the Hospital].[2] In accordance with the order of the Bankruptcy Court, plaintiff released files, depositions, expert reports and non-work product documents to the new law firm.
19. The documents, pleadings, depositions and all other work completed by plaintiff in preparing the defense of the Thompson litigation are currently being utilized and relied upon by the new law firm in the defense of the claim to the benefit of the insurer, Defendant St. Paul Fire and Marine Insurance Company.
20. Defendant has failed to pay plaintiff in full for the legal work and fees expended on behalf of the defense of [the Hospital], all of which were reasonable and incurred in the course of representing and defending [the Hospital] in the Thompson litigation.
Jordan Keys asked the court to award it more than $67,000 in unpaid legal services allegedly provided to the Hospital, together with interest, costs and counsel fees.

II.

THE TRIAL COURT'S RULING
Jordan Keys filed its action on or about October 18, 2002. St. Paul filed a motion to dismiss the amended complaint for failure to state a claim upon which relief may be granted or, in the alternative, for summary judgment. On October 30, 2003, the trial judge granted the motion to dismiss. The judge rejected Jordan Keys' claim of implied contract upon the following grounds:
In the present case, Plaintiff and [the Hospital] had an express contract requiring [the Hospital] to pay for legal work rendered by Plaintiff's firm. An implied contract cannot stand in the face of an express one. A third party cannot be held liable under an implied contract for work done under an explicit contract between two different parties merely because the third party benefits from the work. American Inv. & Management Co. v. Arab Banking Corp., 1993 U.S. Dist. LEXIS 1716 (D.D.C. February 17, 1993); Decatur Prod. Credit Ass'n v. Murphy, 119 Ill.App.3d 277, 74 Ill.Dec. 765, 456 N.E.2d 267, 274 (1983). Plaintiff cannot now seek to recover legal fees owed by [the Hospital] from St. Paul, a non-party to the contract. Finally, Plaintiff has not established that St. Paul was the entity for which the legal work was performed; rather, [the Hospital] was the entity to which Plaintiff firm rendered services. Further, Plaintiff has failed to present facts indicating that St. Paul was put on notice by unambiguous circumstances that St. Paul was expected to pay for services.
The judge did not explicitly address Jordan Keys' claim that St. Paul was liable to it on a theory of unjust enrichment. Jordan Keys filed a timely notice of appeal.

III.

LEGAL ANALYSIS

A. Applicable legal standard.

The standard applicable to motions pursuant to Super. Ct. Civ. R. 12(b)(6) to dismiss a complaint for failure to state a claim upon which relief may be granted was correctly articulated by the trial judge in her order granting the motion:

*62 In deciding a motion to dismiss, the [c]ourt accepts as true all allegations in the Complaint and views them in a light most favorable to the nonmoving party. Owens v. Tiber Island Condominium Ass'n, 373 A.2d 890 (D.C.1977). Dismissal is impermissible unless it appears beyond doubt that the plaintiff can prove no set of facts in support of her claim, which would entitle her to relief. Conley v. Gibson, 355 U.S. 41, 41-45, 78 S.Ct. 99, 2 L.Ed.2d 80 (1957); Abdullah v. Roach, 668 A.2d 801 (D.C.1995).
On appeal, we review the trial court's ruling de novo, and apply the same substantive standard as that applied by the trial judge in this case. Abdullah, 668 A.2d at 804.

B. Jordan Keys'"implied-in-fact" theory.

We agree with the trial judge that Jordan Keys' amended complaint, viewed in the light most favorable to the pleader, does not allege the elements of an implied-in-fact contract. "An implied-in-fact contract is a true contract, containing all necessary elements of a binding agreement; it differs from other contracts only in that it has not been committed to writing or stated orally in express terms, but rather is inferred from the conduct of the parties in the milieu in which they dealt." Vereen v. Clayborne, 623 A.2d 1190, 1193 (D.C.1993) (quoting Bloomgarden v. Coyer, 156 U.S.App.D.C. 109, 116, 479 F.2d 201, 208 (1973)). In Vereen, we described as follows the requirements for recovery under a contract implied-in-fact:
(1) valuable services being rendered; (2) for the person sought to be charged; (3) which services were accepted by the person sought to be charged, used and enjoyed by him or her; and (4) under such circumstances as reasonably notified the person sought to be charged that the [person rendering the services] expected to be paid by him or her.
623 A.2d at 1193 (citations omitted).
We find it unnecessary to determine whether Jordan Keys has satisfied the first three of the foregoing requirements, for its claim incontrovertibly founders on the fourth. At the time Jordan Keys provided services to the Hospital, St. Paul was not placed on notice that Jordan Keys expected to be paid for those services by St. Paul. On the contrary, as Jordan Keys acknowledges, it contracted to be paid by its client, the Hospital, and not by the Hospital's excess carrier, a party with which Jordan Keys had no agreement at all.
Indeed, since an "implied-in-fact" contract is a true contract, Vereen, 623 A.2d at 1193, the contention that such a contract exists between Jordan Keys and St. Paul fails at the very outset. Jordan Keys does not allege that St. Paul broke an agreement to pay for Jordan Keys' legal services. On the contrary, Jordan Keys complains that St. Paul refused to agree to pay. Under these circumstances, the "implied-in-fact" contract theory is untenable.

C. Jordan Keys'"unjust enrichment" theory.

Jordan Keys also asserts a claim in quasi contract for "unjust enrichment." Jordan Keys argues that it provided legal services to the Hospital but has not been paid for these services; that St. Paul has now received the benefit of these very services, but has not paid for them; and that St. Paul has therefore been unjustly enriched at Jordan Keys' expense. Jordan Keys relies, inter alia, on our decision in 4934, Inc. v. District of Columbia Dep't of Employment Servs., 605 A.2d 50 (D.C.1992), in which this court summarized the applicable principles:

*63 The modern law of unjust enrichment and restitution has its roots in the common law concept of quasi-contract. At common law there were cases in which the courts, in the absence of an actual contract, nevertheless imposed "a duty ... under certain conditions upon one party to requite another in order to avoid the former's unjust enrichment." Bloomgarden v. Coyer, 156 U.S.App. D.C. 109, 116, 479 F.2d 201, 208 (1973) (footnote omitted). To achieve this result, the courts devised "a legal obligation closely akin to a duty to make restitution," id. at 118, 479 F.2d at 210, which they called a quasi-contract. From the beginning a quasi-contract has been openly acknowledged to be a "[l]egal fiction invented by common law courts to permit recovery by contractual remedy in cases where, in fact, there is no contract, but where circumstances are such that justice warrants a recovery as though there had been a promise.... It is ... founded on considerations of justice and equity, and on [the] doctrine of unjust enrichment." BLACK'S LAW DICTIONARY 324 (6th ed.1990). When the essential facts are not in dispute, as in this case, the question of whether a quasi-contract should be recognized is one of law. Bloomgarden v. Coyer, supra, 156 U.S.App. D.C. at 119, 479 F.2d at 211.
Unjust enrichment occurs when a person retains a benefit (usually money) which in justice and equity belongs to another. Hillyard v. Smither & Mayton, Inc., 76 A.2d 166, 167 (D.C.1950); Sparks v. Gustafson, 750 P.2d 338, 342 (Alaska 1988); Partipilo v. Hallman, 156 Ill.App.3d 806, 811, 109 Ill.Dec. 387, 510 N.E.2d 8, 11 (1987); see RESTATEMENT OF RESTITUTION § 1 comment a (1937). In such a case, the recipient of the benefit has a duty to make restitution to the other person "if the circumstances of its receipt or retention are such that, as between the two persons, it is unjust for [the recipient] to retain it." Id. § 1 comment c. Thus the doctrine of unjust enrichment depends on whether it is fair and just for the recipient to retain the benefit, not on whether the person or persons who bestowed the benefit had any duty to do so.... A claim of unjust enrichment does not require fault on the part of the recipient of the benefit. "His innocence in receiving the benefit does not mean that his retention of that benefit without payment is just." Partipilo v. Hallman, supra, 156 Ill.App.3d at 810, 109 Ill.Dec. 387, 510 N.E.2d at 11 (citations omitted).
Id. at 55-56.
In Bradkin v. Leverton, 26 N.Y.2d 192, 309 N.Y.S.2d 192, 257 N.E.2d 643 (1970), the New York Court of Appeals provided the following explanation of the theory underlying claims sounding in quasi contract:
Quasi contracts are not contracts at all, although they give rise to obligations more akin to those stemming from contract than from tort. The contract is a mere fiction, a form imposed in order to adapt the case to a given remedy. (See KEENER, THE LAW OF QUASI CONTRACTS [1893], p. 14.) Briefly stated, a quasi-contractual obligation is one imposed by law where there has been no agreement or expression of assent, by word or act, on the part of either party involved. The law creates it, regardless of the intention of the parties, to assure a just and equitable result. (See, e.g., Dentists' Supply Co. v. Cornelius, 281 App. Div. 306, 308, 119 N.Y.S.2d 570, 571, aff'd, 306 N.Y. 624, 116 N.E.2d 238; Dermott v. State of New York, 99 N.Y. 101, 109 1 N.E. 242, 245; see, also, Miller v. Schloss, 218 N.Y. 400, 407, 113 N.E. 337, 339; Ward *64 v. Taggart, 51 Cal.2d 736, 741, 336 P.2d 534; RESTATEMENT, RESTITUTION, § 1; 1 CORBIN, CONTRACTS [1963], § 19; 1 WILLISTON, CONTRACTS [3d ed., 1957], § 3A.) "The obligation implied under such circumstances," the court wrote in the Dermott case (99 N.Y. at p. 109, 1 N.E., at p. 246), "is such as justice would dictate, and must conform to what the court may assume would have been the agreement of the parties if the situation had been anticipated and provided for." The applicable principle finds [an] apt and more full statement in Miller v. Schloss, 218 N.Y. 400, 407, 113 N.E. 337, 339, supra:

A quasi or constructive contract rests upon the equitable principle that a person shall not be allowed to enrich himself unjustly at the expense of another. In truth it is not a contract or promise at all. It is an obligation which the law creates, in the absence of any agreement, when and because the acts of the parties or others have placed in the possession of one person money, or its equivalent, under such circumstances that in equity and good conscience he ought not to retain it, and which ex aequo et bono belongs to another. Duty, and not a promise or agreement or intention of the person sought to be charged, defines it. It is fictitiously deemed contractual, in order to fit the cause of action to the contractual remedy.
Id. at 645 (footnote omitted). As these passages reveal, the claim of unjust enrichment asserted by Jordan Keys is based on equitable principles, and it is not contingent upon the niceties of the law of contracts. Indeed, it is not a claim of breach of contract at all. Rather, the question before us is whether it is fair and just, under all of the circumstances, for St. Paul to receive Jordan Keys' non-work product documents without compensating Jordan Keys for them.
St. Paul asserts that the principles of quasi contract and unjust enrichment have no application where, as is alleged by the carrier to be true in the present case, the plaintiff's rights are governed by an express contract. St. Paul relies, inter alia, on the emphasized words in our statement in the 4934, Inc., case that "[absent] an actual contract, [unjust enrichment] ... impose[s] ... `a duty ... under certain conditions upon one party to requite another in order to avoid the former's unjust enrichment.'" 605 A.2d at 55 (emphasis added). St. Paul also quotes the court's observation in Bloomgarden, 156 U.S.App. D.C. at 118, 479 F.2d at 210, that "[t]here is, of course, no need to resort to [quasi contract] when the evidence sustains the existence of a true contract, either express or implied in fact." St. Paul's argument makes sense where a contract exists between the party seeking recovery on the basis of unjust enrichment and the party alleged to have been unjustly enriched. One who has entered into a valid contract[3] cannot be heard to complain that the contract is unjust, or that it unjustly enriches the party with whom he or she has reached agreement.
The equities may be quite different, however, where A, who claims that B has been unjustly enriched at A's expense, has a contract with C rather than with B. It is not at all clear to us that in such a situation, the existence of a contract with C should automatically bar A's claim of unjust enrichment against B. See, e.g., Paschall's, *65 Inc. v. Dozier, 219 Tenn. 45, 407 S.W.2d 150, 155-56 (1966); Commerce P'ship 8098 Ltd. P'ship v. Equity Contracting Co., 695 So.2d 383, 387-88 (Fla.Dist.Ct.App.1997) (both holding that a plaintiff may recover in quasi contract for unjust enrichment against one not a party to the contract under which the plaintiff provided services).[4] In the present case, there is no contract, express or implied in fact, between Jordan Keys and St. Paul, and we are not prepared to sustain the judgment upon the ground that the existence of an agreement between Jordan Keys and the Hospital would necessarily bar any recovery by Jordan Keys against St. Paul based on quasi contract or unjust enrichment.
In any event, we need not decide the merits of St. Paul's contention that the contract between Jordan Keys and the Hospital precludes recovery against St. Paul for unjust enrichment, for in our view, St. Paul has not been unjustly enriched. We reach this conclusion because, as counsel for Jordan Keys acknowledged at oral argument, it was contemplated from the outset of the malpractice suit instituted by the Thompsons against the Hospital that St. Paul would receive the benefits of Jordan Keys' representation of the Hospital. This understanding was implicit in Jordan Keys' theory, stated in its complaint, that St. Paul was a third party beneficiary of the contract between Jordan Keys and the Hospital. See note 1, supra. If the Thompsons won a verdict greater than $1,000,000, then St. Paul would be obliged to pay the plaintiffs any part of the judgment in excess of that amount. For this reason, according to Jordan Keys, St. Paul "directed and controlled the litigation"[5] pursuant to "written litigation guidelines" and required Jordan Keys to provide St. Paul with regular and detailed reports on the status of the case. Because Jordan Keys, as counsel for the Hospital, was also automatically representing the interests of St. Paul, St. Paul's requests for, and expectations of, full information from Jordan Keys were altogether reasonable. As Jordan Keys asserted in the trial court, "[t]he defendant was informed of the progress of the litigation at virtually every step of the way." Thus, Jordan Keys concedes that when the Bankruptcy Court ordered Jordan Keys to make the information in its files available to St. Paul without having to compensate the Hospital or its *66 attorneys for it, St. Paul received nothing that it would not have expected to be given had the Hospital not gone bankrupt. Accordingly, in our view, although St. Paul benefited from Jordan Keys' work on behalf of the Hospital, St. Paul was not unjustly enriched.
There can be no doubt that the Hospital's bankruptcy significantly altered the legal terrain insofar as Jordan Keys was concerned. Jordan Keys had expected to be fully compensated by the Hospital, and its client's bankruptcy shattered these expectations.[6] Nevertheless, in the absence of some unanticipated and unjust enrichment of St. Paul, the loss resulting from the Hospital's inability to meet its obligations must be borne by the party that contracted with the Hospital, namely, Jordan Keys.
Finally, Jordan Keys asserts that, in selecting new counsel to defend the Thompson case, St. Paul made no claim that Jordan Keys' performance was unsatisfactory. Therefore, according to Jordan Keys, "[t]he logical inference then is that St. Paul used the bankruptcy of its insured to cut legal fees and save money by switching counsel after discovery had closed. This is not equitable." It is unclear to us that a change of counsel after the close of discovery could reduce the carrier's legal fees, for the new attorneys would have to familiarize themselves with a complex case and "get up to speed," while the Jordan Keys lawyers presumably already had the requisite familiarity. Moreover, following the bankruptcy, St. Paul was arguably in a worse position than it had previously anticipated as an excess carrier, for it was compelled to step in, assume an active role, and incur the expenses of a legal defense before the self-insured Hospital had completed its anticipated task of defending against the first $1,000,000 of the Thompsons' claims for damages.
In any event, St. Paul had the right to select its own attorneys when it took over the defense of the case. At the time St. Paul replaced counsel, Jordan Keys either was entitled to compensation for its documents from St. Paul (under principles of implied-in-fact contract or quasi contract) or it was not. The resolution of this issue could not turn on the carrier's motive for deciding to change attorneys, and we have concluded that Jordan Keys is not entitled to recovery under either of these theories.[7] Accordingly, the judgment is
Affirmed.
NOTES
[1]  In the trial court, Jordan Keys also alleged that St. Paul was a third party beneficiary of the contract between Jordan Keys and the Hospital, and that as a third party beneficiary, the carrier was liable to Jordan Keys for the Hospital's unpaid counsel fees.
[2]  Neither the order of the Bankruptcy Court nor the submissions made to that court are part of the record in this case, and we are unable to determine if that court made any determination relevant to the issues presented in this appeal. St. Paul has not asserted a defense of res judicata or collateral estoppel.
[3]  Our discussion is not intended to address the doctrine of unconscionability, which is not at issue here.
[4]  The venerable RESTATEMENT OF RESTITUTION § 110(1937), now two-thirds of a century old, provides as follows:

A person who has conferred a benefit upon another as the performance of a contract with a third person is not entitled to restitution from the other merely because of the failure of performance by the third person.
(Emphasis added.) A more extensive discussion of the subject appears in RESTATEMENT (THIRD) OF RESTITUTION AND UNJUST ENRICHMENT § 29 (Tentative Draft No. 3, (2004)):
(1) A person who has conferred a benefit on a recipient as the performance of a contract with a third person is entitled to restitution from the recipient upon the failure of performance by the third person, but only as necessary to prevent unjust enrichment. In this context, the conclusion that a recipient would be unjustly enriched by the retention of a given benefit requires a determination that
(a) absent liability in restitution, the claimant will not be compensated for the performance in question, and the recipient will retain the benefit of the claimant's performance free of any liability to pay for it;
(b) liability in restitution will not subject the recipient to an obligation from which it was understood by the parties that the recipient would be free; and
(c) liability in restitution will not subject the recipient to a forced exchange.
(Emphasis added.)
[5]  For example, according to Jordan Keys, St. Paul approved the selection of the Hospital's expert witnesses.
[6]  We were advised at oral argument that, as a creditor of the Hospital, Jordan Keys had filed a claim against the bankruptcy but was in a position to recover only "pennies on the dollar." Jordan Keys thus plainly considered the Hospital liable.
[7]  We note further that, although the record is not revealing on the point, the realities of the situation suggest that St. Paul's receipt of the documents from Jordan Keys was an anticipated and bargained for benefit. The premium charged by St. Paul as an excess carrier was undoubtedly less than it would have been if St. Paul had provided unlimited coverage, with all of the obligations and exposure to liability that this would entail. See 1 ERIC MILLS HOLMES, APPLEMAN ON INSURANCE § 2.16, at 323 (2d ed.1996). Realistically, St. Paul's receipt of a smaller premium may well have been part of the bargaining and give-and-take that took place. See, e.g., Commerce P'ship, 695 So.2d at 388 (quoting Paschall's, Inc., 407 S.W.2d at 155)) ("The most significant requirement for a recovery on quasi contract is that the enrichment to the defendant be unjust. Consequently, if the [beneficiary] has given any consideration to any person for the improvements, it would not be unjust for him to retain the benefit without paying the furnisher.") (emphasis added).
