Hacienda del Cerezo, Moss Farms, Energy Concerned Homeowners, and Santa Fe Northwest Advisory Council (“interve-nors”) appeal the dismissal of their com*1034plaint in intervention by the district court. We have jurisdiction pursuant to 28 U.S.C. § 1291, and we reverse and remand.
I
This case involves a dispute among the parties stemming from the proposed construction of a powerline by the Public Service Company of New Mexico (“PNM”) through part of Santa Fe County. The powerline, which PNM states is necessary to improve power transmission in the Santa Fe area, is to be built aboveground and will cross Indian, federal, and private lands. PNM began obtaining approvals for the powerline in the 1980s.
In December 1998, the County of Santa Fe (“County”) filed suit in New Mexico state court against PNM seeking to enjoin construction of the powerline. The County alleged that the powerline project was in violation of its Land Development Code (“Code”) because PNM had not obtained a required development permit and was not burying the powerline. After initially failing in an attempt to remove the case to federal court, PNM filed a third-party complaint against the United States Bureau of Land Management (“BLM”) in the state court action. BLM then removed the case to federal court.
Intervenors — who live in the vicinity of the proposed powerline — had initially moved to intervene on February 13, 1999, and were granted permission to intervene by the district court on January 31, 2000. On February 2, 2000, pursuant to a settlement agreement between them, both the County and PNM moved under Federal Rule of Civil Procedure 41(a)(2) to dismiss with prejudice the County’s claims against PNM. Despite intervenors’ objections, the district court granted the motion. The settlement agreement provided that PNM was not required to obtain a development permit from the County for its project and that an amendment to the Code enacted in 1998 did not apply to the project. (1 Appellants’ App. at 351.)
In February 2000, intervenors filed their complaint-in-intervention with the district court. Intervenors’ complaint primarily sought (1) injunctive relief against the powerline project as an anticipatory public nuisance, and (2) a writ of mandamus requiring the County to enforce the Code against the project.1 In particular, the complaint alleged that the County’s settlement agreement “lacks any basis in fact or law.” (2 id. at 361.) PNM moved to dismiss intervenors’ complaint under Federal Rule of Civil Procedure 12(b)(6) for failure to state a claim upon which relief could be granted. In January 2001, the district court heard argument on PNM’s motion and granted it in a ruling from the bench. Intervenors now appeal the dismissal of their complaint; they also appeal the district court’s approval of the County’s and PNM’s Rule 41 motion.
II
Because the district court dismissed intervenors’ complaint under Rule 12(b)(6), we review that dismissal de novo, applying the same standards as the district court. Sutton v. Utah State Sch. for the Deaf & Blind, 173 F.3d 1226, 1236 (10th Cir.1999). In reviewing a motion for dismissal under Rule 12(b)(6), we accept as true “all well-pleaded factual allegations in the amended complaint,” and those allegations are “viewed in the light most favorable to the nonmoving party.” Id. As a result, a “12(b)(6) motion should not be granted unless it appears beyond doubt *1035that the plaintiff can prove no set of facts in support of Ms claim which would entitle him to relief.” Id. (quotation omitted.) “The court’s function on a Rule 12(b)(6) motion is not to weigh potential evidence that the parties might present at trial, but to assess whether the plaintiffs complaint alone is legally sufficient to state a claim for wMch relief may be granted.” Miller v. Glanz, 948 F.2d 1562, 1565 (10th Cir.1991). We also “must indulge all reasonable inferences in favor of the plaintiff.” Curtis Ambulance of Fla., Inc. v. Bd. of County Comm’rs, 811 F.2d 1371, 1374 (10th Cir.1987).
In deciding a Rule 12(b)(6) motion, a federal court may only consider facts alleged within the complaint. Miller, 948 F.2d at 1565. There are two exceptions to this rule. First, a district court may review “mere argument contained in a memorandum in opposition to dismiss” without converting the Rule 12(b)(6) motion into a motion for summary judgment. Id. (quotation omitted). Second, “the district court may consider documents referred to in the complaint if the documents are central to the plaintiffs claim and the parties do not dispute the documents’ authenticity.” Jacobsen v. Deseret Book Co., 287 F.3d 936, 941 (10th Cir.2002).
Because all of intervenors’ claims are state law claims, we apply New Mexico state law in our analysis. We review the district court’s conclusions of state law de novo. Blanke v. Alexander, 152 F.3d 1224, 1228 (10th Cir.1998). Our goal is to apply state law such that the “result obtained in the federal court should be the result that would be reached in [the state] court,” and we are therefore required to follow New Mexico law “as announced by that state’s highest court.” Id. (quotations omitted). Where there is no decision of the state’s highest court that has addressed an issue of that state’s law, we “must predict how the State’s highest court would rule.” Stuart v. Colo. Interstate Gas Co., 271 F.3d 1221, 1228 (10th Cir.2001). “In doing so, the federal court is free to consider all resources available, including decisions of [the state’s] courts, other state courts and federal courts, in addition to the general weight and trend of authority.” Id. (quotation omitted). Specifically, the rulings of an intermediate appellate court of the state that are on point provide “dat[a] for ascertaining state law which [are] not to be disregarded by a federal court unless it is convinced by other persuasive data that the highest court of the state would decide otherwise.” Sports Unlimited, Inc. v. Lankford Enters., Inc., 275 F.3d 996, 1000-01 (10th Cir.2002) (quoting West v. Am. Tel. & Tel. Co., 311 U.S. 223, 237, 61 S.Ct. 179, 85 L.Ed. 139 (1940)) (emphasis removed).
Ill
We first address the intervenors’ request for a writ of mandamus. Under New Mexico law, “mandamus lies to compel the performance of an affirmative act by [an official] where the duty to perform the act is clearly enjoined by law and where there is no other plain, speedy and adequate remedy in the ordinary course of law.” Lovato v. City of Albuquerque, 106 N.M. 287, 742 P.2d 499, 501 (1987). On appeal, the parties’ sole dispute is whether enforcement of the Code by the County against PNM was “clearly enjoined by law” or was instead discretionary.
A
It is well-established in New Mexico that once a petitioner “show[s] that there was a valid ordinance in existence and that it was being violated, the duty cast upon the [local government] becfomes] ministerial and subject to en*1036forcement by mandamus.” State ex rel. Edwards v. City of Clovis, 94 N.M. 136, 607 P.2d 1154, 1157 (1980).2 Neither party on appeal argues that any relevant part of the Code is invalid.3 Thus, we need only address whether PNM has violated or will violate the Code through construction of its powerline. If PNM is in violation of the Code, then the County has a non-discretionary duty to enforce the Code against PNM, a duty that may be enforced through a writ of mandamus under New Mexico law.
Prior to 1998, the Santa Fe Code prescribed: “A development permit shall not be required for, and provisions of the Code shall not apply to, utility easements, utility rights-of-way, and construction of utility line extensions.” (3 Appellants’ App. at 710.)4 In November 1998, however, the County amended the language in the Code that addressed utility lines. The new provisions require a development permit for “all development; including utilities, utility easements, utility rights-of-way, and construction of utility lines and facilities.” (3 id. at 924.) The amendment also requires that “[a]ll utility lines shall be placed underground” unless an exemption is granted by the Board of County Commissioners. (3 id. at 925.)
Intervenors argue that PNM’s project violates the Code in one of two ways. If the project was begun before the 1998 amendment, then the project is in violation of the ordinance because PNM did not obtain a development permit and did not fully comply with other provisions of the Code. Alternatively, if the project was commenced after the enactment of the 1998 amendment, then the project is in violation of that amendment because PNM never obtained a development permit and the powerline will be built aboveground. A violation of either the pre-amendment Code or the 1998 amendment to the Code would be sufficient for intervenors’ mandamus claim to succeed.
As a prelude to the detailed analysis that follows, we provide a summary to aid the reader. Because this case was resolved by the district court on a Rule 12(b)(6) motion, we must assume to be true the intervenors’ factual allegation that the settlement agreement between the County and PNM “lacks any basis in fact or law” to the extent that the parties agreed that the powerline project is not covered by the Code. (2 Appellants’ App. at 361.)
The first basis for intervenors’ mandamus claim — the allegation that PNM’s powerline project violated the Code prior to the 1998 amendment — requires the court to interpret the meaning of the pre-1998 Code. Under New Mexico law, in order to answer the question whether PNM’s project is in violation of the pre-1998 Code, we must consider the prior history of enforcement and application of the Code to similar projects. Assuming *1037intervenors’ allegations to be true, the pri- or history would show that the pre-1998 Code applied to PNM’s project and that the County therefore had a duty to enforce the Code against the project. Thus, on a Rule 12(b)(6) motion, it was inappropriate for the district court to dismiss interve-nors’ mandamus claim to the extent that the claim was based on the County’s failure to enforce the provisions of the pre-1998 Code against PNM’s project.
The second basis for intervenors’ mandamus claim is- an allegation that the project is in violation of the 1998 amendment to the Code. Intervenors’ argument can succeed only if PNM — relying on a belief that it did not need a permit from the County — had never made significant expenditures on the project and had never begun actual construction of the powerline prior to the 1998 amendment of the Code. Intervenors must show the existence of this factual predicate in order to establish that the County had a ministerial duty to enforce the post-amendment Code. Under New Mexico law, mandamus would still be available to require the performance of a ministerial duty that depends on a showing of such a factual predicate. This is true even where a public official has previously concluded that the factual predicate did not exist and that therefore the ministerial duty was never implicated — as the County did in this case by concluding that the 1998 amendment did not apply to the PNM project because construction of the power-line began prior to its enactment. In such a situation, the party seeking mandamus relief must show that there was no genuine factual basis for the official’s factual conclusions. At the Rule 12(b)(6) stage, inter-venors need only allege that there was no genuine factual basis for the County’s conclusion that the Code does not apply to the powerline project. Because, again, inter-venors made such an allegation in their complaint, dismissal on a Rule 12(b)(6) motion was improper.
B
According to PNM, the Code language prior to 1998 provided it with a blanket exemption from any regulation by the County when it undertook construction within a utility right-of-way or easement. Thus, the powerline project could never have been in violation of any provision of the pre-amendment Code. Intervenors respond that the language of the Code provision only applies to the utility right-of-way or easement itself, and not to construction within the right-of-way or easement.5 {See Appellants’ Br. at 24 (stating that the relevant provision “does not apply to the construction of [a] main electricity transmission line”).)
We conclude that the language of the pre-amendment Code is ambiguous, with neither explanation entirely convincing. PNM’s interpretation of the provision ignores the fact that the provision places “construction” next to utility line extensions alone, and not next to utility easements or rights-of-way — implying that the exception only covers construction connected with utility line extensions and not construction connected with easements or rights-of-way. Intervenors’ interpretation, on the other hand, would draw the scope of the exception very narrowly, applying only *1038to the establishment of an easement or right-of-way.
Where the language of a local ordinance is ambiguous, New Mexico courts will rely on prior administrative interpretations of the relevant ordinance or statute. The case of High Ridge Hinkle Joint Venture v. City of Albuquerque, 126 N.M. 413, 970 P.2d 599 (1998), is instructive on this point. In High Ridge, a landowner and the city disputed whether the term “outside storage and activity” in the zoning ordinance meant “outside storage and related storage activities” or “outside storage and other outside activities.” Id. at 600. Finding the language ambiguous, the court noted that city officials in charge of enforcing the ordinance had consistently adopted the landowner’s interpretation over a long period of years. Id. at 601. The court then held that this long-standing interpretation of the ordinance by the city officials meant that the city was bound to that interpretation of the ordinance and could only change it through legislative action. Id. at 602 (“ ‘If an administrative gloss is indeed found to have been placed on a clause, the municipality may not change such a de facto policy, in the absence of legislative action, because to do so would presumably violate legislative intent.’ ” (quoting Conforti v. City of Manchester, 141 N.H. 78, 677 A.2d 147, 149 (1996)) (emphasis removed)).
According to intervenors, County enforcement officials consistently interpreted and applied the pre-amendment Code to require a development permit for construction within a utility, easement or right-of-way. If this allegation is true, then the pre-amendment Code required PNM to obtain a development permit — which PNM has admittedly failed to do — and construction of its powerline project would violate the Code. Moreover, it would also mean that the County was without power to change the meaning of the pre-amendment Code to exclude PNM’s powerline project unless the County legislatively changed the Code. The settlement of the lawsuit alone would have been insufficient.
PNM also argues that its project is a “utility line extension” such that it was exempt under the pre-amendment Code. Intervenors respond that the term “utility line extension” only applies to connections between main utility lines and individual buildings, rather than the large transmission line to be constructed by PNM. The Code provides no definition of the term “utility line extension.” (3 Appellants’ App. at 843-55.) Given the ambiguity of the term’s meaning, the prior history of the 'County’s interpretation and enforcement of the Code will again be relevant in determining whether the “utility line extension” exemption covers PNM’s project.
Thus, whether the pre-amendment Code applies to PNM depends in part on whether County officials had consistently enforced and applied the pre-amendment Code to require a development permit for construction activities similar to this project. Any evidence as to whether such a consistent enforcement and application of the pre-amendment Code existed should be used by the district court to interpret the Code and determine, as a matter of law, what the meaning of the Code was on this point prior to 1998. See High Ridge, 970 P.2d at 601. If the district court concludes that the past enforcement history means that the Code applied to PNM’s project prior to 1998, then intervenors would succeed on their mandamus claim.
PNM argues that we should defer to the County’s legal interpretation of ambiguous sections of the Code, citing Hyde v. Taos Municipal-County Zoning Authority, 113 N.M. 29, 822 P.2d 126, 128 (1991), and Huning Castle Neighborhood Association v. City of Albuquerque, 125 N.M. 631, 964 *1039P.2d 192, 198 (1998). According to PNM, that deference means that mandamus is unavailable. Respectfully, PNM’s argument confuses the deference that- New Mexico courts provide to agency interpretations of a statute with an absolute bar against mandamus in situations where statutes require interpretation by the courts.
First, there is no absolute bar against mandamus simply because the relevant statute or ordinance that determines whether an agency has a ministerial duty is open to interpretation. New Mexico courts have regularly relied on their own interpretation of statutes to conclude that an agency was vested -with a ministerial duty which could be enforced through mandamus. See, e.g., City Comm’n v. State ex rel. Nichols, 75 N.M. 438, 405 P.2d 924, 927-30 (1965) (construing state election laws in order to determine whether a city had a ministerial duty to hold a referendum election); City of Santa Rosa v. Jaramillo, 85 N.M. 747, 517 P.2d 69, 71-73 (1973) (construing state liquor statutes and rejecting Attorney General opinions regarding those statutes in concluding that mandamus was proper).
Moreover, even if deference to an agency interpretation of a statute is proper in considering a mandamus claim, this would not necessarily prevent a court from adopting a contrary interpretation of the statute. In cases where the New Mexico courts have deferred to agency interpretations of statutes or ordinances, the courts have “accorded substantial weight” to the interpretation of the agency charged with enforcement of the statute. Klumker v. Van Allred, 112 N.M. 42, 811 P.2d 75, 80 (1991). Because this is substantial — not conclusive — weight, New Mexico courts may nonetheless conclude that an agency’s interpretation of an ordinance is improper and cannot be sustained. See Perea v. Baca, 94 N.M. 624, 614 P.2d 541, 544 (1980) (granting mandamus relief based on a rejection of the state agency’s interpretation of the relevant state liquor statutes despite the canon of construction that “[a]n administrative construction given a statute by the agency charged with its administration is persuasive and will not be lightly overturned”); Downtoum Neighborhoods Ass’n v. City of Albuquerque, 109 N.M. 186, 783 P.2d 962, 968 (N.M.Ct.App.1989) (rejecting a city’s interpretation of an ordinance because it was inconsistent with state law).
If there is strong evidence that the County consistently enforced and applied the Code against similar projects, then the County’s interpretation of the Code would be improper despite any deference that it is owed. Again, because intervenors alleged that the settlement agreement between the County and PNM “lacks any basis in fact or law” to the extent that the parties agreed that the powerline project is not covered by the Code (2 Appellants’ App. at 361), intervenors have also alleged that such an enforcement history exists. And if there is evidence of just such an enforcement history, there would be a ministerial duty on the part of the County to enforce the Code against PNM’s project, and mandamus would lie. Dismissal of the mandamus claim based on this argument by the district court was improper.
C
In analyzing the intervenors’ mandamus claim to the extent that it is based on the 1998 Code amendment, we begin with a discussion of how the amendment might apply to PNM’s powerline project. We then determine whether New Mexico law would allow a mandamus claim in a situation such as this one.
*10401. Applicability of the 1998 Code Amendment to PNM’s Powerline Project
While the parties do not dispute that the language of the 1998 Code amendment would cover PNM’s project, they nonetheless disagree over whether that amendment may be properly applied'to the project.
PNM argues that the amendment does not apply to the project because (1) the Code specifically states that projects “on which actual construction was lawfully begun before the effective date of ... any amendment ]” to the Code will not be covered by that amendment (3 Appellants’ App. at 610); (2) the County has interpreted the amendment as not applying to the powerline project, an administrative interpretation to which we must defer under New Mexico law; and (3) PNM had obtained “vested rights” in the powerline project such that New Mexico law prohibits the application of the amendment to the project.
Under the Code, any amendment will not apply to ongoing projects so long as “actual construction” has begun.6 (3 id. at 610.) The Code defines “actual construction” as “1) permanently fastening construction materials in permanent position; or 2) substantial demolition or removal of an existing building or other structure preparatory to construction of a replacement.” (Id.) If actual construction of the powerline had begun prior to the enactment of the 1998 Code amendment, under the Code’s own terms the amendment would not apply to the powerline project.
Before the district court, intervenors conceded that PNM had begun surveying for the powerline project before the amendment was passed. (2 id. at 563.) Based on that concession, the district court concluded that the 1998 amendment did not apply to the powerline project.
Everyone agrees that they did survey work out there, and that they got started, in that sense. I think we’re drawing too fine a line to say that we’ve got to have poles up there, that surveying was not starting the line; therefore, the new ordinance does not apply as the county found and agreed to.
(2 id. at 587) However, the plain language of the Code requires that the permanent fastening of “construction materials” in “permanent position” must occur for there to be “actual construction.” We cannot see how placement of flags or otherwise surveying the route of a powerline — the only points that intervenors conceded (2 id. at 563) — constitutes a permanent fastening of construction materials in permanent position.
PNM points out that during hearings leading to County enactment of the Code amendment, the ordinance was described as “applfying] prospectively.” (1 id. at 327.) Based on this statement, PNM argues that the County “itself understood the 1998 amendment” as not applying to the power-line project. (Appellees’ Br. at 20.)
PNM’s quote from the hearing is taken out of context. The statement explained why the Code amendment would not require existing powerlines to be buried. (See 1 Appellants’ App. at 327 (“In other words, we would not require Jemez Pueblo to come in and underground all the utility lines which they use right now.”).) The *1041statement does not mean that the County did not intend for the amendment to apply to powerline projects on which no construction had yet begun, as is allegedly the case with PNM’s powerline project. Indeed, at an earlier County hearing there was a strenuous debate between representatives of PNM and the County over the fairness of enacting an amendment that clearly would affect PNM’s powerline project. (See 1 id. at 94-111.)
PNM’s third argument is that, under New Mexico law, application of the 1998 Code amendment to its powerline project would result in an improper retroactive application of the law in violation of Article IV, § 34 of the New Mexico Constitution.7 Under New Mexico law, the determination of whether a local zoning ordinance amendment may apply retroactively to a particular project depends on whether the project owner has obtained “vested rights” in the project; once a landowner has achieved “vested rights,” subsequent changes to the zoning laws cannot apply. See, e.g., Brazos Land, Inc. v. Bd. of County Comm’rs, 115 N.M. 168, 848 P.2d 1095, 1097 (1993). For “vested rights” to exist, “there must be approval by the regulatory body” and “a substantial change in position in reliance thereon.” Id.
Although the County has never granted PNM any approval to build its powerline, if PNM is correct that the pre-amendment Code did not apply to its project, PNM was never required to obtain any sort of approval to construct its powerline prior to the enactment of the amendment. Therefore, it would not need approval to obtain vested rights.8
The district court held that, as a matter of law, surveying alone by PNM was sufficient to satisfy the requirement of a “substantial change in position.” (2 Appellants’ App. at 587.) There are few New Mexico cases that address what “substantial change in position” means, and no New Mexico case has held that surveying alone is sufficient for vested rights. See Brazos Land, 848 P.2d at 1096-97 (holding that the submission of a preliminary plat application alone did not result in “substantial reliance or change in position”); see also El Dorado at Santa Fe, Inc. v. Bd. of County Comm’rs, 89 N.M. 313, 551 P.2d 1360, 1362-63, 1366-67 (1976) (holding that rights had vested where a landowner had surveyed, placed monuments, and sold subdivided properties in reliance on the approval of a subdivision); Chilili Coop. Ass’n v. Sundance Mountain Ranches, Inc. (In re Sundance Mountain Ranches, Inc.), 107 N.M. 192, 754 P.2d 1211, 1212 (1988) (holding that vested rights applied based on the “expenditures, change of position, and reliance” of the developer after obtaining approval, but without providing any specifics as to the nature of the expenditures or change in position).9
*1042One way a “substantial” reliance or change in position may be shown is through the expenditure of a “considerable sum of money.” Sundance Mountain, 754 P.2d at 1213 (quotation omitted). Surveying is not the expenditure of a “considerable sum of money” when considered in the context of the cost of this entire project, nor would it appear to constitute any other form of substantial reliance, such as the sale of subdivided property to third parties. El Dorado, 551 P.2d at 1362-63.
While surveying alone does not qualify, other questions may remain for resolution by the trial court in properly raised pleadings or on the merits as to whether PNM’s powerline project might have obtained vested rights. We will not consider such questions at this juncture.
2. Applicability of New Mexico Mandamus Law
As noted above, the parties do not dispute that the language of the 1998 Code amendment covers PNM’s powerline project. Therefore, the question here is not one of the interpretation of the meaning of the 1998 Code amendment, but instead of the application of that amendment to PNM’s project.
PNM insists that the “district court ... engaged in no factual determinations of its own” and that it merely concluded that the “County’s determination that PNM began construction of the Project before the enactment of the ordinance ... could not be ‘second-guessed’ in a mandamus proceeding.” (Appellees’ Br. at 18 (emphasis removed).) In essence, PNM’s argument is that the County, in entering into the settlement agreement, resolved the question of whether the 1998 Code amendment applied to the project in PNM’s favor by determining that one of the two conditions discussed above had been met by PNM. According to PNM, the County’s determination is a discretionary decision by the County which cannot be second-guessed in a mandamus proceeding.10
*1043The key question becomes whether, under New Mexico law, mandamus is appropriate to compel ministerial action by a public official (in this case, enforcement of the Code) where that ministerial act depends upon a determination by the agency as to the existence of certain facts (in this case, that PNM had neither begun actual construction of the powerline project nor had made significant expenditures on the project prior to the 1998 Code amendment).
Even where the ministerial duty of a public official is triggered by factual determinations, mandamus still may be proper:
[I]t is ... well established that mandamus will lie to compel the performance of mere ministerial acts or duties imposed by law upon a public officer to do a particular act or thing upon the existence of certain facts or conditions being shown, even though the officer be required to exercise judgment before acting.
State ex rel. Four Corners Exploration Co. v. Walker, 60 N.M. 459, 292 P.2d 329, 331 (1956); see also Sender v. Montoya, 73 N.M. 287, 387 P.2d 860, 863 (1963) (stating that “mandamus would practically never issue” if “an inflexible rule” were followed that “mandamus is inappropriate where interpretation and judgment are necessary”), overruled on other grounds by State ex rel. Reynolds v. Molybdenum Corp. of Am., 83 N.M. 690, 496 P.2d 1086, 1092 (1972).
PNM argues that the facts will show that the 1998 Code amendment did not apply to its project and that therefore the ministerial duty to enforce the Code was never triggered. Given the Rule 12(b)(6) posture of the case, this is an allegation that the relevant facts that would trigger the ministerial duty are disputed and that mandamus is therefore inappropriate. At first glance, New Mexico case law seems unclear as to whether allegations of disputes over facts may be litigated in a mandamus proceeding where resolution of those disputes is required to determine whether a public official has a ministerial duty. Some cases have stated that if there is any dispute whatsoever between the parties over the facts that would give rise to a ministerial duty, mandamus will not lie. See Rainaldi v. Pub. Employees Ret. Bd., 115 N.M. 650, 857 P.2d 761, 765 (1993) (“Mandamus is used to enforce an existing right, not to resolve material issues of fact.”); Kiddy v. Bd. of County Comm’rs, 57 N.M. 145, 255 P.2d 678, 682 (1953) (stating that “where the existence of facts which would require the performance on part of the board or officer remains the subject of judicial determination, mandamus is not proper”); Brantley Farms v. Carlsbad Irrigation Dist., 124 N.M. 698, 954 P.2d 763, 769 (1998) (holding an application for mandamus was legally insufficient because the parties disputed the “underlying facts giving rise to the public board’s duty to perform”); Concerned Residents for Neighborhood Inc. v. Shollenbarger, 113 N.M. 667, 831 P.2d 603, 606 (1991) (stating that “[i]f issues of fact are raised, then mandamus should not issue, since it is only a method by which an existing right is enforced”).
On the other hand, there are also cases — even one of the cases cited above— that have allowed findings of fact in a mandamus proceeding where those findings determined whether a ministerial duty was imposed on the public official. See Rainaldi, 857 P.2d at 763, 766 (noting that the parties disputed whether relevant facts were proven and stating that mandamus was a proper remedy because the petitioner “was able to satisfy the district *1044court that the facts supported his position and that the Board was required to perform by direction of law regardless of its own opinion as to the propriety or impropriety of doing so”); Nichols, 405 P.2d at 929-30 (noting that petitioner and the city disputed the total number of registered voters in the city, which would determine whether a petition was signed by a sufficient proportion of the registered voters such that the city was required to place the petition on the ballot, and stating that because the trial court found that the requisite proportion was met by the petition, “nothing remains to be done by the City except to comply”); see also City of Santa Rosa, 517 P.2d at 72-73 (‘Where the discretion is as to the existence of facts entitling the relator to the thing demanded, if facts are clearly proved or admitted, mandamus will lie.” (quotation omitted)).
The conflict in the cases and language, however, is more apparent than real. If there is any genuine dispute over the underlying facts based on admissible evidence, then mandamus should not lie, because the officer has exercised his discretion to resolve the factual dispute. However, if there is no admissible evidence that could support the factual determination of the officer, then the officer has no discretion in the matter. See Sender, 387 P.2d at 862 (stating that in the context of the application of mandamus to a judicial officer, “where the express mandatory conditions for a dismissal are clearly established, and without contradiction, the court was without discretion in the matter” (quotation omitted)). In other words, we interpret the language in the cases that state that mandamus will not he to resolve “issues of fact” to mean that mandamus will not lie to resolve genuine issues of fact based on admissible evidence. Otherwise, a public agency or officer could use baseless allegations of material factual disputes in their answer to a mandamus petition to force the dismissal of that petition and render the mandamus process ineffective whenever there is a factual predicate for the ministerial duty of an official.
We emphasize that the standard of whether there is an “issue of fact” is quite a low one. Indeed, it might be compared to the burden on the party opposing a motion for summary judgment, who need only show that there is a “genuine issue of material fact.” If the agency or officer makes such a showing, then it had discretion to resolve the factual issue in the manner that it did, and mandamus is an inappropriate remedy. Moreover, the party seeking mandamus must also provide sufficient evidence supporting its version of the facts — i.e., that the agency or official made the wrong decision — such that the court must conclude that this version has been “clearly proved.” Santa Rosa, 517 P.2d at 73.
For intervenors’ mandamus action to be dismissed in the present case, therefore, the parties opposing mandamus must show that there was a genuine factual dispute regarding whether PNM had begun “actual construction” of the powerline project or had made substantial expenditures of money prior to the enactment of the 1998 Code amendment, with the expenditures made in good faith reliance on an exemption from the Code, and as defined by applicable law.
However, the corollary to this conclusion — that a genuine dispute of material fact based on admissible evidence will result in the dismissal of a mandamus action — is that dismissal of a mandamus action is inappropriate at the Rule 12(b)(6) stage where a plaintiff has alleged that there is no genuine dispute of material fact. Thus, if intervenors’ complaint can *1045be fairly read to allege that there is no genuine dispute of material fact — i.e., that there is clear and uncontradicted evidence that PNM had not begun actual construction prior to the 1998 amendment and had no vested rights in the project — then accepting as true the well-pleaded factual allegations of the complaint under Sutton, 173 F.3d at 1236, intervenors have successfully stated a claim with respect to the 1998 Code amendment, and 12(b)(6) dismissal by the district court was error.
As noted above, when considering a Rule 12(b)(6) motion, we are required to take the facts alleged in intervenors’ complaint as true and to “indulge all reasonable inferences in favor of the plaintiff,” Curtis Ambulance, 811 F.2d at 1374. Intervenors specifically alleged that the settlement agreement between the County and PNM “lacks any basis in fact or law” to the extent the parties agreed that the powerline project is not covered by the Code. (2 Appellants’ App. at 361.) We are required to presume that this allegation is true. In particular, we must presume that there is clear and uncontradicted evidence that PNM had not begun actual construction prior to the 1998 amendment and had no vested rights in the project. We must also therefore presume that intervenors could successfully show that the 1998 Code amendment applied to PNM’s project.
In discussing the issue of whether the 1998 amendment applied to PNM’s project, the parties referred to the record in both their briefs and oral argument in order to contest the relevant factual issues. But, as noted above, when reviewing a decision based on a Rule 12(b)(6) motion a federal court may not consider that record. See Miller, 948 F.2d at 1565 (“Failure to convert to a summary judgment motion and to comply with Rule 56 when the court considers matters outside the plaintiffs complaint is reversible error.”).
The settlement agreement entered into by the County and PNM may be considered by us, because it is a document referred to in the complaint and it is a document that is central to the plaintiffs claim whose authenticity is not in dispute. See Jacobsen, 287 F.3d at 941. The settlement agreement does state that the power-line project “shall not be subject to” the Code as amended in 1998, “because construction of the [powerline] was begun pri- or to the passage of said” amendment. (1 Appellants’ App. at 351.) However, this portion of the settlement agreement cannot establish that there was a genuine issue of material fact over when construction of the powerline had begun. It is this very document that the complaint alleges “lacks any basis in fact or law.” (2 id. at 361.) A document that is alleged by one party to be without any factual basis cannot be relied upon by the other party to establish that there is a genuine issue of material fact.11 The contrary conclusion would effectively mean that a local government could immunize from mandamus claims any decision that required the resolution of a question of fact by simply drafting a document that purported to resolve that question.12
*1046IV
Intervenors’ remaining claim is for anticipatory public nuisance. The district court did not specify the grounds on which it dismissed intervenors’ complaint, stating simply, “I don’t think there’s any way that this would ever be found to be a nuisance.” (2 Appellants’ App. at 588.)
In explaining the district court’s decision, the parties on appeal have relied exclusively on State ex rel. Vill. of Los Ranchos de Albuquerque v. City of Albuquerque, 119 N.M. 150, 889 P.2d 185 (1994); the applicability of Los Ranchos was also advanced by PNM as a ground for dismissal below (2 Appellants’ App. at 484). According to PNM, under Los Ranchos its project is immune to any anticipatory nuisance claim.
At issue in Los Ranchos was the construction by the City of Albuquerque of a bridge across the Rio Grande River and a nearby irrigation ditch. 889 P.2d at 189. A neighboring municipality, the Village of Los Ranchos de Albuquerque, sought to prevent construction of the bridge by seeking an injunction against it as a public nuisance. Id. at 190-91. The New Mexico Supreme Court took the case for review “to consider whether a public works project is subject to abatement as a public nuisance when it has been duly authorized by law and has, pursuant to law, been reviewed and approved by concerned municipal, state, and federal agencies.” Id. at 191. The court concluded that as a matter of law such a project could not be subject to abatement as an anticipatory public nuisance. Id.
In establishing this rule, the Los Ranchos court emphasized the two requirements for the exemption from anticipatory public nuisance claims: (1) there must be “due authorization,” and (2) the project must be a “public works project.” Id. at 200. PNM argues that both requirements are met.
“Due authorization” means that the project is in “conformance with all the federal, state, and local laws, rules, and regulations pertinent to that particular project.” Id. Because PNM never received a development permit from the County of Santa Fe for its powerline project, PNM could have “due authorization” only if it never needed such a permit. But, as noted above, inter-venors allege that the Code applied to the PNM project and therefore that PNM needed a development permit for the project. At the 12(b)(6) stage, we must assume that those allegations are true; dismissal by the district court of this claim was therefore error.
However, we have a more fundamental difficulty with the district court’s conclusion that Los Ranchos applies to the present ease. The court in Los Ranchos explained that,
when a complaint of public nuisance is raised, public works projects are fundamentally different from private construction projects. A public project carries with it the presumption that it is for the public good. Proof that it will be a nuisance must be balanced against its benefit for the public as a whole.
A public works project, unlike a private construction project, is a product of the exercise of the legislative power. The presumption is that the project is publicly scrutinized and balanced against all interests, public and private, upon which it will have impact. As the history of [this] project demonstrates, this process can take several decades and can involve government agencies, the voting public, advocates of private interests, and the courts. At the conclusion of this balancing of interests, a determination is made that, despite any adverse *1047impacts, the project serves the public health, welfare, safety, and rights.
Id. at 199-200 (citations omitted, emphasis added). Although considered a “public utility” under New Mexico law, N.M. Stat. Ann. § 62-3-3, PNM is essentially a private corporation, not a public governmental agency. PNM’s actions are not the “product of the exercise of the legislative power,” Los Ranchos, 889 P.2d at 199, but instead the product of the exercise of the power of PNM’s corporate officers, directors, and shareholders. The powerline project planned by PNM is a project planned by a private entity; in Los Ranc-hos, the bridge project was the project of a municipal government — the City of Albuquerque — whose members were accountable through elections to its citizens. While we presume that a politically accountable governmental agency has adequately balanced the multiple and conflicting interests, we indulge in no such presumption regarding a private corporation that is not politically accountable and that is not run by an elected government.13
V
Finally, intervenors challenge the district court’s grant of the County’s and PNM’s Rule 41(a)(2) motion to dismiss with prejudice the County’s lawsuit. We review a district court’s grant of a Rule 41(a)(2) motion for abuse of discretion. Moore v. C.R. Anthony Co., 198 F.2d 607, 608 (10th Cir.1952).
Rule 41(a)(2) requires a court to review a motion by a plaintiff to dismiss a complaint if the action has proceeded beyond service of an answer or of a motion for summary judgment, and there is not unanimous agreement among all parties supporting the dismissal. Fed.R.Civ.P. 41(a)(2) (“[A]n action shall not be dismissed at the plaintiffs instance save upon order of the court and upon such terms and conditions as the court deems proper.”). The purpose of the rule is “primarily to prevent voluntary dismissals which unfairly affect the other, side, .and to permit the imposition of curative conditions.” Clark v. Tansy, 13 F.3d 1407, 1411 (10th Cir.1993) (quotation omitted). When considering a motion to dismiss, “the important aspect is whether the opposing party will suffer prejudice in the light of the valid interests of the parties. It is the prejudice to the opposing party, rather than the convenience of the court, that is to be considered in passing on a motion for dismissal.” Id. (quotations and alterations omitted); see also Ohlander v. Larson, 114 F.3d 1531, 1537 (10th Cir.1997) (“Absent *1048‘legal prejudice’ to the defendant, the district court normally should grant such a dismissal.”). Among the factors to be considered by the district court in making this evaluation are: “the opposing party’s effort and expense in preparing for trial; excessive delay and lack of diligence on the part of the movant; insufficient explanation of the need for a dismissal; and the present stage of litigation.” Ohlander, 114 F.3d at 1537. This list of factors “is by no means exclusive,” and factors that are “unique to the context of the case” must also be considered. Id. In reaching its conclusion, “[t]he district court should endeavor to insure substantial justice is accorded to both parties,” and therefore the court “must consider the equities not only facing the defendant, but also those facing the plaintiff.” Id.
Intervenors argue that the dismissal will act as a “shield against the Resident Intervenors’ Complaint in Intervention, particularly its claim for a writ of mandamus compelling the County to enforce” the Code, because res judicata would apply to bar any future suit by the County. (Appellants’ Br. at 48.) In granting the motion, the district court rejected intervenors’ arguments, concluding that “[s]ince the parties are different in the suit-in-intervention, I find that res judicata would not apply” and therefore intervenors “would not be prejudiced by the voluntary dismissal.” (1 Appellants’ App. at 344.) The district court further noted that the County “will be seriously prejudiced if forced to remain in the case since the purpose of the settlement was to avoid the expenses and inconvenience of litigation.” (Id.)
We disagree with the district court that res judicata will not negatively affect the intervenors. It is certainly true that neither the settlement agreement nor dismissal of the County’s lawsuit will act through either res judicata or collateral estoppel to bar intervenors from succeeding on the merits in their claim for a writ of mandamus against the County, because they are not a party to that agreement. However, dismissal of the County’s suit does foreclose intervenors from obtaining relief even if their writ of mandamus claim succeeds. Intervenors’ amended complaint specifically requests as relief under their writ of mandamus cause of action that the County be “command[ed] and compelled] ... to enforce the provisions” of the Code against PNM. (2 id. at 367.) But if the County is allowed to dismiss its suit with prejudice, that dismissal will act as res judicata and prevent the County from filing any additional claims or suits against PNM concerning alleged violations of the Code by the powerline project. (See 1 id. at 347 (stating, in the settlement agreement, that “the parties are released from all present claims ... arising with respect to this action, and all such claims are forever barred”).) By granting the Rule 41(a)(2) motion, the district court immunized PNM against any future suit by the County related to the powerline project, and therefore made it impossible for intervenors to obtain the relief that they sought under their writ of mandamus cause of action. Given the particular circumstances of the case — where the relief sought by intervenors is the prosecution of a cause of action by the very plaintiff seeking dismissal with prejudice of that cause of action — this is a clear example of “legal prejudice.”14 The district court *1049abused its discretion in granting the motion.
PNM argues, however, that we should adopt a rule that the district court must grant a motion to dismiss under Rule 41(a)(2) where the dismissal will be with prejudice. See Smoot v. Fox, 340 F.2d 301, 302-03 (6th Cir.1964); see also Shepard v. Egan, 767 F.Supp. 1158, 1165 (D.Mass.1990) (“[I]t is difficult, both practically and logistically, to imagine a court denying a plaintiffs motion to dismiss her own action with prejudice.”).
We see no need for a new and distinct rule for motions to dismiss with prejudice. In most cases, the normal analysis will result in the district court granting the plaintiffs motion to dismiss with prejudice. Consider that the defendant will have obtained a judgment on the merits that vindicates his rights and precludes any future suit by the plaintiff. See, e.g., Sec. & Exch. Comm’n v. Lorin, 869 F.Supp. 1117, 1119 (S.D.N.Y.1994) (granting the government’s motion to dismiss claims with prejudice because under the standard analysis there is no legal prejudice to defendant). But there will be circumstances where granting a plaintiffs motion to dismiss with prejudice may adversely affect the defendant or, more likely, other parties to the litigation. In such situations, a blanket rule that the court must grant the plaintiffs motion would lead to injustice. To the contrary, in such circumstances the motion should instead be denied. See, e.g., Atwood v. Pac. Mar. Ass’n, 432 F.Supp. 491, 495-96 (D.Or.1977) (refusing to dismiss with prejudice plaintiffs’ claims against a union because it would adversely affect the co-defendant employers); Beaver Assocs. v. Cannon, 59 F.R.D. 508, 512 (S.D.N.Y.1973) (refusing to dismiss with prejudice a plaintiff shareholder’s derivative claims against a corporation because it “might result in the loss to the corporation of its only forum for considering the merits, if any, of the asserted derivative claim”). The instant case is an example of the rare circumstance where dismissal with prejudice of a plaintiffs claims would adversely impact another party to the litigation and, correlatively, why we should reject PNM’s proposed rule.
We are mindful of the fact that denying a plaintiffs motion to dismiss with prejudice leaves the plaintiff in an awkward situation — the plaintiff is no longer desirous of pursuing the litigation and may seek effective dismissal of his case through non-prosecution or poor litigation tactics. See Shepard, 767 F.Supp. at 1165 (“Could the Court force the plaintiff to continue discovery, or offer evidence? Can or should the Court require plaintiff to litigate a claim when plaintiff herself has attempted to dismiss it?”). These are important factors for a court to consider in deciding whether to grant the motion to dismiss with prejudice; they are part of the requirement that the court consider “the equities not only facing the defendant, but also those facing the plaintiff.” Ohlander, 114 F.3d at 1537. However, in this case we see little danger of such an awkward situation arising. The County’s suit against PNM can remain inactive while intervenors pursue their cause of action; if intervenors are not successful in further efforts to reach and *1050prevail on the merits of their claims, that will end the matter. On the other hand, if intervenors do succeed on the merits of their claims, they will necessarily have already proven the County’s case against PNM, as they will have shown that PNM was so clearly in violation of the Code that the County had a clear duty to enforce it against PNM.
YI
The judgment of the district court is REVERSED, and this case is REMANDED for proceedings consistent with this opinion.
. Intervenors also raised stand-alone claims for declaratory and injunctive relief. Interve-nors have not challenged on appeal the district court’s dismissal of those claims.
.The cases cited by PNM from New Mexico and the Tenth Circuit for the proposition that "interpretation and enforcement of a zoning code under New Mexico law are not ministerial” (Appellees' Br. at 22) are not on point. Those cases involve the amendment of zoning ordinances, Hart v. City of Albuquerque, 126 N.M. 753, 975 P.2d 366, 368-69 (1999), or approval of a submitted subdivision plat, Hyde Park Co. v. Santa Fe City Council, 226 F.3d 1207, 1209 (10th Cir.2000); Norton v. Vill. of Corrales, 103 F.3d 928, 929-30 (10th Cir.1996).
. PNM argued below that the 1998 Code amendment as applied to it was invalid special or retroactive legislation, and that the Code could not apply to federal lands. The district court did not rely on those arguments in ruling on the 12(b)(6) motion, and they are not before us in this appeal.
. A development permit is a requirement for any construction or other development activity within Santa Fe County.
. Intervenors also argue that other provisions of the pre-amendment Code applied to the powerline regardless of the language apparently exempting utility-rights-of-way and easements. However, given the plain language of the exemption — “provisions of the Code shall not apply to, utility easements, utility rights-of-way” (3 Appellants' App. at 710 (emphasis added)) — this argument fails. {See 3 id. at 604 (stating that "the Code” refers to the entirety of the County’s land-úse ordinance).)
. To be exempt from any future amendment, a development permit (if required by the Code at the time construction began) must also have been issued. (3 Appellants' App. at 610.) If the pre-amendment Code provisions did apply to PNM's project, then PNM could not qualify for this exemption because it never obtained the required development permit for its project.
.Intervenors argue that retroactivity analysis is misplaced because the 1998 amendment provisions — particularly the requirement that all utility lines be placed underground — are environmental regulations which might permissibly apply retroactively to existing uses. However, as noted above, the discussion in the relevant County hearings shows that the County did not intend for the 1998 Code amendment to apply to existing uses. (See 1 Appellants’ App. at 327.)
. Of course, if the pre-amendment Code did apply to the project, PNM has never accrued any vested rights in the project.
. El Dorado has broad language stating that, in the context of land subdivision, once a subdivision plat is approved, rights have vested. 551 P.2d at 1366 (“Upon compliance with the statutory prerequisites to subdivision and sale by a subdivider, followed by a determination of the board of county commissioners that such compliance had in fact occurred, rights vest in the subdivider which cannot thereafter be withheld, extinguished or *1042modified except upon due process of law.”). However, later New Mexico cases have required a showing of substantial reliance and have cited El Dorado for this proposition. See Brazos Land, 848 P.2d at 1097; Chilili Coop., 754 P.2d at 1213.
The broad language in El Dorado cannot control in this case for two reasons. First, El Dorado's reasoning and conclusions appear to have been limited to the specific context of subdivision approval by localities, rather than covering the broad context of all zoning. Second, if we strictly followed El Dorado’s rule, then whenever a prior zoning ordinance did not require any approval whatsoever for a particular action, any landowner would automatically obtain "vested rights” to undertake that action at any time in the future — even after the ordinance had been amended to require approval' — because the landowner would have had permission to undertake the activity without a permit in the past.
. PNM raises a number of other arguments as to why mandamus is inappropriate. First, according to PNM, the enforcement provisions of the Code give the County discretion in deciding whether to enforce. However, the provisions cited by PNM only describe the process by which the County may determine if violations exist and begin enforcement proceedings. (See 3 Appellants’ App. at 620-21.)
Second, PNM argues that intervenors failed to exhaust their administrative remedies before seeking mandamus relief, citing State ex rel. Hyde Park Co. v. Planning Commission, 125 N.M. 832, 965 P.2d 951, 953-54 (1998). Intervenors should not be required formally to initiate a written complaint against PNM when the County had already initiated its own action against PNM. This is particularly so where intervenors were required to participate in this litigation if they wished to prevent the County from dismissing its case against PNM, a dismissal that — as discussed below— would seriously have prejudiced intervenors.
Third, PNM argues that provisions of New Mexico state law give the County discretion in deciding whether to enforce. The New Mexico courts have already interpreted the relevant statutory provisions and have made it clear that enforcement of a zoning ordinance *1043against violations is not discretionary. See Edwards, 607 P.2d at 1157.
. In our de novo review of the Rule 12(b)(6) dismissal, we owe no deference to factual findings the district court made, implicit or otherwise, in approving the settlement agreement in its Rule 41(a)(2) order. As discussed below, we hold that the district court's issuance of a Rule 41(a)(2) order of dismissal was an abuse of discretion. We see no reason to accord the settlement agreement any special authority by virtue of its incorporation in an order that we reverse.
. Moreover, the settlement agreement does not address the other basis for intervenors' mandamus claim — whether the County had consistently interpreted the Code prior to 1998 to require a development permit for powerline projects.
. That various government agencies approved the powerline project, including the state agency that regulates PNM, does not necessarily make the powerline a “public works project.” While the New Mexico Public Utility Commission ("Commission”) had authority to approve the location of certain "transmission lines” and ensure that they do not "impair important environmental values,” N.M. Stat. Ann. § 62-9-3 (repealed effective July 1, 2003), this provision does not apply to render PNM's proposed powerline a public works project. The provision defines "transmission line” as a line "designed for or capable of operations at a nominal voltage of two hundred thirty kilovolts or more.” Id. at § 62-9-3(B). PNM's proposed powerline would be a 115 kilovolt line, and thus the Commission determined that § 62-9-3 was not applicable to the project. Pub. Serv. Co. of N.M., 1998 WL 996465 at *8. (N.M.P.U.C. Oct. 19, 1998). Consequently, the Commission limited the scope of inquiry requiring environmental and cultural factors to the question of whether PNM had obtained all necessary permits and easements to complete the project. Id, at *9. Because the Commission did not independently review the environmental impact and location of PNM's powerline project, we need not decide whether an exercise of the Commission’s regulatory authority under § 62-9-3 would transform a private corporation's project into a public works project.
. We reach this conclusion although we recognize that most of the traditional factors to be considered in this analysis weigh in favor of dismissal. There is no evidence that there was "excessive delay and lack of diligence” on the part of the County or PNM before seeking dismissal, Ohlander, 114 F.3d at 1537, and there seems to be adequate reason *1049for the County's desire to settle — namely the expense and time of litigation and the uncertainty of succeeding on the merits against PNM. The "present stage of litigation,” with the scheduled trial date still a number of months away at the time that the Rule 41(a)(2) motion was made, likewise does not indicate that the motion should have been denied. However, we reiterate that such factors are "by no means exclusive,” id., and that they should not necessarily override factors that are "unique to the context of [the] case,” id.