
    [No. A093673.
    First Dist., Div. Two.
    Mar. 26, 2002.]
    GROTH BROS. OLDSMOBILE, INC., Plaintiff and Respondent, v. STEVEN V. GALLAGHER, Defendant and Appellant.
    
      Counsel
    Edward Wesley Poison for Defendant and Appellant.
    Estrada & Thomson, William Douglas Thomson; Pritchard & Kay and John Christophe Clark for Plaintiff and Respondent.
   Opinion

KLINE, P. J.

Introduction

Steven V. Gallagher appeals from an order of the Alameda County Superior Court denying his application for indemnity for defense costs pursuant to Corporations Code section 317 from Groth Bros. Oldsmobile, Inc. (Groth Bros.). Gallagher incurred costs and attorney fees in defending himself in an action brought by William M. Groth, Jr. (plaintiff) against him and other defendants. After the court’s favorable tentative ruling on Gallagher’s demurrer to plaintiff’s action, but before hearing on the demurrer, plaintiff voluntarily dismissed its action against Gallagher. Gallagher argues he was entitled to indemnity from Groth Bros, for his costs and expenses in defending the action under either subdivision (d) or (e)(4) of Corporations Code section 317 and that:

(1) The court erred in refusing to vacate plaintiff’s voluntary dismissal and to enter a ruling sustaining the demurrer and a judgment dismissing with prejudice plaintiff’s action as to him;
(2) He is entitled to mandatory indemnity under Corporations Code section 317, subdivision (d) because he was successful on the merits;
(3) The court erred in interpreting Corporations Code section 317, subdivision (e)(4) to require court approval of the voluntary dismissal before he could obtain permissive indemnity from the court.

Gallagher also seeks his costs and fees in connection with this appeal.

Factual and Procedural Background

Plaintiff filed a verified complaint on September 10, 1999, against Gallagher and others, alleging two derivative causes of action on behalf of Groth Bros., and an additional cause of action entitled “conspiracy.” Gallagher answered the complaint. Groth Bros., joined by Gallagher, moved pursuant to Corporations Code section 800, subdivision (c) to require plaintiff to post security as a prerequisite to prosecution of the derivative causes of action. The trial court granted Groth Bros.’s motion and required plaintiff to post security in the sum of $50,000 or, in the alternative, to amend his complaint to eliminate the derivative causes of action. Plaintiff did not post security, but chose to file a first amended complaint eliminating the derivative causes of action and containing causes of action for involuntary dissolution of the corporation, removal of directors and injunctive relief. These were not directed to Gallagher. Gallagher demurred to the first amended complaint on the grounds that the dissolution and removal causes of action did not state a cause of action against him and that the remaining causes of action for conspiracy and injunctive relief were derivative in nature and barred by the court’s previous ruling. Plaintiff did not file opposition to Gallagher’s demurrers, but instead unsuccessfully attempted to file a second amended complaint without leave of court.

On April 18, 2000, the trial court issued a tentative ruling sustaining Gallagher’s demurrers without leave to amend and directing that Gallagher be dismissed from the action. Plaintiff’s counsel apparently indicated that plaintiff would contest the tentative ruling, as he appeared at the demurrer hearing on April 19, 2000. At that time plaintiff’s counsel advised the court that because the clerk had rejected his attempt to file a second amended complaint, plaintiff earlier that morning had filed a dismissal without prejudice of the entire action as to Gallagher pursuant to Code of Civil Procedure section 581, subdivision (c). Counsel for Gallagher objected, requesting the court to vacate the voluntary dismissal and enter a judgment of dismissal following the sustaining of the demurrers without leave to amend. The court concluded it lacked jurisdiction to do so as a result of the filing of the voluntary dismissal by plaintiff before the hearing and final determination of the merits of the demurrers. The court refused to grant Gallagher’s request for orders vacating the voluntary dismissal, sustaining the demurrers without leave to amend, and entering of a judgment of dismissal.

On May 1, 2000, plaintiff filed a second amended complaint that did not name Gallagher as a defendant. On July 28, 2000, Gallagher filed a motion for an order requiring Groth Bros, to indemnify him for defense costs pursuant to Corporations Code section 317, subdivisions (d) and in the alternative (e)(4), based upon his status as a former officer and director of the corporation, and stating that he was sued by plaintiff due to his former corporate capacity. Groth Bros, opposed the motion. On or about June 28, 2000, the board of directors of Groth Bros, adopted a resolution refusing to indemnify Gallagher for the fees and expenses he expended in his defense.

On August 30, 2000, the trial court denied Gallagher’s request for indemnity. In its order and statement of decision, filed September 12, 2000, the court reasoned that a voluntary dismissal did not meet the statutory requirement of “success on the merits” for the purposes of triggering mandatory indemnification pursuant to Corporations Code section 317, subdivision (d). The court also found Gallagher was not entitled to permissive indemnification under Corporations Code section 317, subdivisions (c) and (e)(4), because the voluntary dismissal of Gallagher by plaintiff without prejudice did not involve court approval, as required by the statute. Gallagher timely appealed from the order.

After filing of the appeal by Gallagher, plaintiff apparently posted the $50,000 bond pursuant to Corporations Code section 800, subdivision (c) and then filed a third amended complaint reasserting derivative causes of action on behalf of Groth Bros, and renaming Gallagher as a defendant to those causes of action.

On May 31, 2001, Groth Bros, moved this court for a dismissal of Gallagher’s appeal on the grounds that the trial court’s order of September 12, 2000, denying his request for indemnification was not an appealable order. We denied the motion on June 29, 2001.

Discussion

The parties agree that the standard of review of the lower court’s denial of Gallagher’s application for indemnity is de novo, as we are engaging in analysis and interpretation of Corporations Code section 317 and Code of Civil Procedure section 581, subdivision (c) and their application to undisputed facts. (See Eisenberg et al., Cal. Practice Guide: Civil Appeals and Writs (The Rutter Group 2001) ¶ 8:111, p. 8-53, citing International Engine Parts, Inc. v. Feddersen & Co. (1995) 9 Cal.4th 606, 611 [38 Cal.Rptr.2d 150, 888 P.2d 1279], among others.)

Gallagher contends he was entitled to mandatory indemnification under Corporations Code section 317, subdivision (d), requiring success on the merits. This argument is first premised upon his assertion that the trial court erred in refusing to vacate the voluntary dismissal and enter a judgment dismissing the complaint with prejudice as to him. We agree the court erred in concluding it lacked jurisdiction to vacate the dismissal and to rule on the demurrer.

We are persuaded that the voluntary dismissal in this case falls within judicially created exceptions to the general rule that a plaintiff may voluntarily dismiss an action at any time before “actual commencement of trial.” (Code Civ. Proc., § 581, subd.(c).)

“ ‘[T]he right of a plaintiff to voluntarily dismiss an action before commencement of trial is not absolute.’ [Citation.] There are statutory exceptions to a plaintiff’s right of voluntary dismissal, and ‘other limitations have evolved through the courts’ construction of the term “commencement of trial.” ’ [Citation.] The meaning of the term ‘trial’ is not restricted to jury or court trials on the merits, but includes other procedures that ‘ “effectively dispose of the case.” ’ (Wells v. Marina City Properties, Inc. (1981) 29 Cal.3d 781, 785 [176 Cal.Rptr. 104, 632 P.2d 217].) [¶] A plaintiff is precluded from voluntarily dismissing an action without prejudice under various circumstances short of a full trial. Those circumstances include a general demurrer sustained without leave to amend, a general demurrer sustained with leave to amend where no amendment is made within the allotted time, and where all issues have been deemed admitted in defendant’s favor. [Citations.]” (Mary Morgan, Inc. v. Melzark (1996) 49 Cal.App.4th 765, 769 [57 Cal.Rptr.2d 4].)

The California Supreme Court in Wells v. Marina City Properties, Inc., supra, 29 Cal.3d 781 (Wells), explored the reach of the plaintiff’s right to a voluntary dismissal in the context of a ruling on a demurrer. In Wells, the trial court had sustained the defendant’s general demurrer to the plaintiff’s second amended complaint with leave to amend within 30 days. Upon the plaintiff’s failure to amend within the time limit, the defendant moved to dismiss the action with prejudice pursuant to former Code of Civil Procedure section 581, subdivision 3. (Wells, supra, at p. 783.) The plaintiff then sought to voluntarily dismiss the action without prejudice pursuant to former Code of Civil Procedure section 581, subdivision 1 (the predecessor to Code Civ. Proc., § 581, subd. (c).) (Wells, supra, at p. 784.)

The Wells court reaffirmed the holding of Goldtree v. Spreckels (1902) 135 Cal. 666, 668, 672-673 [67 P. 1091] (Goldtree), that the plaintiff’s right to dismiss an action voluntarily “was ended when a trial court order sustained a defendant’s general demurrer without leave to amend.” (Id. at p. 785.) In so holding, Wells “examin[ed] and resolve[d] the apparent conflict between two subdivisions of [former] Code of Civil Procedure section 581. . . . Subdivision 1 gives a plaintiff a right to dismiss his action without prejudice ‘at any time before the actual commencement of trial.’ Subdivision 3, on the other hand, affords a defendant a right to obtain dismissal of such action with prejudice after the trial court has sustained, with leave to amend, defendant’s general demurrer, and plaintiff has failed to so amend. We will conclude that in such a conflict, a defendant’s right to a dismissal with prejudice prevails.” (Id. at p. 783.)

The Wells court refused to extend the right to voluntary dismissal beyond that recognized by Goldtree. (Wells, supra, 29 Cal.3d at pp. 785-788; see Datner v. Mann Theatres Corp. (1983) 145 Cal.App.3d 768, 770 [193 Cal.Rptr. 676].) Wells embraced the reasons set forth in Goldtree for refusing to allow the plaintiff to exercise its right to voluntarily dismiss an action where leave to amend was afforded but not exercised: “We held that the matter having been submitted to the court, a plaintiff no longer had the right to dismiss without prejudice. ‘ “If he could do so, litigation would become interminable, because a party who was led to suppose a decision would be adverse to him could prevent such decision and begin anew, thus subjecting the defendant to annoying and continuous litigation.’ ” ([Goldtree], at p. 671.) An important additional interest has also been identified. ‘But the injustice to the defendant is not the greatest evil of such a practice; the wasting of the time and money of the people in a fruitless proceeding in the courts is something far more serious.’ [Citation.]” (Wells, supra, at pp. 785-786.)

Wells recognized that to allow the plaintiff to voluntarily dismiss without prejudice after allowing the time limit for amendment to pass would run counter to the Legislature’s purpose in amending former Code of Civil Procedure section 581 to “limit [the plaintiff’s] right of voluntary dismissal to the point of the ‘commencement of trial’ ” (Wells, supra, 29 Cal.3d at p. 788) and would subvert the statutory scheme. (Ibid.) “The obvious consequence of such a statutory construction would be to prolong, rather than to terminate, lawsuits. It would not serve the orderly and timely disposition of civil litigation. No good reason appears why encouragement should be given to such tactics, the effect of which is to expose defendants to duplicative ‘annoying and continuous litigation,’ to burden our trial court with ‘fruitless’ proceedings, and to delay the ultimate resolution of the validity of the plaintiff’s pleading. [Citations.]” (Id. at p. 789.)

Wells identified the issue before it as “when does the trial of an issue of law commence?” (Wells, supra, 29 Cal.3d at p. 788.) The court concluded that “once a general demurrer is sustained with leave to amend and plaintiff does not so amend within the time authorized by the court or otherwise extended by stipulation or appropriate order, he can no longer voluntarily dismiss his action pursuant to [former] section 581, subdivision 1, even if the trial court has yet to enter a judgment of dismissal on the sustained demurrer.” (Id. at p. 789.) However, the Wells court also noted in dicta: “(Anticipating another possible source of procedural confusion [citation], we note that such right of voluntary dismissal, which is not barred until expiration of plaintiff’s time to amend after the sustaining of the demurrer, would also not be impaired prior to a decision sustaining the demurrer.)” (Id. at pp. 789-790, original italics.)

Wells was characterized by the court in Datner v. Mann Theatres Corp., supra, 145 Cal.App.3d 768 (Datner) as reaffirming the holding of Goldtree, supra, 135 Cal. 666, 668, 672-763, that a plaintiff may as a matter of right dismiss an action until there has been a hearing on the demurrer filed by a defendant and the matter has been submitted to the court. (See Datner, supra, at p. 770.) Datner relied upon Wells to reverse a trial court’s vacation of a voluntary dismissal where the plaintiff filed a request for voluntary dismissal before hearing on the demurrer, but after the trial judge had indicated in chambers that he had tentatively decided that the demurrer was meritorious. According to Datner. “In the case at bench, not only had the demurrer not been sustained at the time that appellant filed his request for dismissal, but the hearing upon such demurrer had not occurred and was not even set for that day.” (Id. at p. 771.) Responding to the defendant’s argument that the court in chambers had advised counsel it had tentatively decided the demurrer was meritorious and should be sustained, the court was “unpersuaded.” (Ibid.) “We take judicial notice of the fact that many judges presiding in the law departments of superior and municipal courts issue tentative rulings on calendared cases prior to the time of hearing. This procedure is helpful to counsel and tends to expedite judicial administration. [Defendant’s] argument, when analyzed, urges us to declare a new rule of law to the effect that a tentative ruling of the trial court issued during the pendency of a hearing upon a demurrer negates the statutory authority conferred by [Code of Civil Procedure], section 581, subdivision 1. We decline to so declare.” (Ibid.)

M & R Properties v. Thomson (1992) 11 Cal.App.4th 899 [14 Cal.Rptr.2d 579], further explored the effects of a tentative ruling in the context of the defendant’s right to dismiss an action for lack of prosecution under the five-year statute. In that case, the court issued a tentative ruling granting the defendant’s motion to dismiss. The tentative ruling provided that any oral argument would be heard on September 12 at 9:00 a.m. and, consistent with local rules of court, required that a party desiring a hearing on the motion must contact the court and opposing counsel by 4:30 p.m. of the day preceding the hearing. (Id. at p. 901.) The plaintiffs did not request oral argument, but instead filed a request for a voluntary dismissal without prejudice on September 12 at 10:39 a.m. The clerk entered the voluntary dismissal and the trial court vacated it and entered an order of mandatory dismissal. The Court of Appeal affirmed, recognizing that the case involved “the conflicting rights of a defendant to a mandatory dismissal—which is intertwined with the duty of the trial court to dismiss an action for lack of prosecution—and of a plaintiff to a voluntary dismissal.” (Id. at p. 902.) The court determined the defendant’s right was stronger and concluded “that plaintiff’s right to seek a voluntary dismissal is cut off by a ruling granting a defendant’s motion to dismiss the action for lack of prosecution.” (Ibid.) The court reasoned that “the opinion in Wells supports the conclusion that a plaintiff’s right to a voluntary dismissal is cut off no later than the time of a ruling effectively disposing of the case (or at the end of a time period specified in that ruling), whether or not that disposition involves an adjudication of the actual merits of the action.” (Id. at p. 905.)

M & R Properties v. Thomson, supra, 11 Cal.App.4th 899, is numbered among the cases construing local rules or policies on tentative rulings as holding “that when the time window closes and the tentative ruling becomes final, plaintiff’s right to voluntarily dismiss, with or without prejudice, is cut off. [Citations.]” (Weil & Brown, Cal. Practice Guide: Civil Procedure Before Trial (The Rutter Group 2001) 11:25.4, p. 11-12 (Weil and Brown), citing M & R Properties v. Thomson, supra, at pp. 901-902 and Sweat v. Hollister (1995) 37 Cal.App.4th 603, 614-615 [43 Cal.Rptr.2d 399], disapproved on other grounds in Santisas v. Goodin (1998) 17 Cal.4th 599, 609, fn. 5 [71 Cal.Rptr.2d 830, 951 P.2d 399]; see Kyle v. Carmon (1999) 71 Cal.App.4th 901, 915 [84 Cal.Rptr.2d 303] [construing M & R Properties v. Thomson, as holding that a “tentative ruling became formal ruling when plaintiff failed to request hearing by the time allotted”].) These cases interpret Wells to mean that the right to voluntarily dismiss one’s action without prejudice continues until “ ‘some sort of ruling, at least when the motion to dismiss might be denied.’ ” (Weil & Brown, supra, at ¶ 11:25.1, p. 11-11, italics omitted, quoting M&R Properties v. Thomson, supra, at p. 905.)

Nevertheless, several cases have held, in various contexts, that the plaintiff’s right to a voluntary dismissal without prejudice may be cut off where a dispositive motion is pending, but before a ruling thereon. (Hartbrodt v. Burke (1996) 42 Cal.App.4th 168, 1785 [49 Cal.Rptr.2d 562] [voluntary dismissal request filed day before hearing on motion for terminating sanction in a discovery dispute]; Cravens v. State Bd. of Equalization (1997) 52 Cal.App.4th 253, 257 [60 Cal.Rptr.2d 436] [voluntary dismissal request filed after expiration of time to file opposition to a summary judgment motion]; see Weil & Brown, supra, ¶¶ 11:25 - 11:25.10, pp 11-11 to 11-12.) Weil and Brown conclude that “[I]t is unclear whether the mere pendency of a dispositive demurrer or motion cuts off plaintiff’s ‘absolute’ right to dismiss without prejudice.” (Id. at ¶ 11:25, p. 11-11.) They opine that the meaning and effect of the Wells dictum is “unclear.” (Ibid.)

We believe that the facts present in this case directly implicate the policy concerns underlying the Wells holding to such a degree that the policy rationale must prevail over the dicta contained in the Wells parenthetical.

Not only does allowing a plaintiff to file a voluntary dismissal without prejudice in the face of a tentative ruling that the court will sustain the demurrer without leave to amend waste the time and resources of the court and other parties and promote annoying and continuous litigation, but we are persuaded that allowing such dismissal in the circumstances of this case undermines both the tentative ruling system and the statutory scheme providing for mandatory indemnity of corporate officers in specific situations.

Under the Alameda County Unified Superior Court Rules, in effect in April 2000 at the Gale/Schenone Hall of Justice in Pleasanton where this matter was heard, a tentative ruling was available after 5:00 p.m. the day preceding the afternoon hearing in the law and motion department. (Super. Ct. Alameda County, Local Rules (eff. Jan. 2000), appen. to chs. 4 and 5.) A party contesting a tentative ruling was required to leave a message on the tentative ruling voice mail system and with opposing counsel requesting argument by 10:00 a.m. the day of the hearing. (See Super. Ct. Alameda County, Local Rules in effect in Apr. 2000, rule 5.8 and appen. to chs. 4 and 5.) “Failure to follow the procedure of the Court will result in the tentative ruling becoming the Court’s order.” (Id., at rule 5.8.) The record does not disclose whether plaintiff’s counsel followed the procedure set forth to contest the tentative ruling, however, we may assume that counsel did so as the hearing occurred the afternoon of the day following the tentative ruling. It is obvious that plaintiff did not intend to oppose the tentative decision. Never having filed any written opposition to the demurrer, plaintiff was almost certain to lose. Nor did plaintiff’s counsel ever present any argument to the court that the tentative decision was erroneous or legally untenable. Rather, plaintiff’s counsel appeared at the hearing for the sole purpose of advising the court that, because he had voluntarily dismissed the action as to Gallagher, the court had no jurisdiction to act upon the demurrer. Plaintiff thus used the window of opportunity presented by the tentative decision procedure not to contest the tentative ruling, but to “buy time” to voluntarily dismiss his action after learning of the court’s ruling, but before it could become final. (Cf. M & R Properties v. Thomson, supra, 11 Cal.App.4th 899, 901 in which the tentative ruling granting a motion to dismiss for lack of prosecution became the ruling of the court determining the rights of the parties upon the plaintiff’s failure to contest it within the time set forth in the local rules.) Plaintiff subsequently posted the security and filed a third amended complaint, once again naming Gallagher as a defendant. Such disingenuous behavior not only wastes the resources of the court and the opposing parties, but undercuts the tentative ruling system.

The tentative ruling system which had long been informally utilized in many superior courts was formally acknowledged by California Rules of Court, rule 324, effective July 1, 1992, nearly a decade after the dicta in Wells, supra, 29 Cal.3d 781 and Christensen v. Dewor Developments (1983) 33 Cal.3d 778, 785 [191 Cal.Rptr. 8, 661 P.2d 1088] stating that the plaintiff retains the right to voluntarily dismiss an action until the trial court rules on the pending demurrer or motion. Consequently, our Supreme Court has had no occasion to consider the voluntary dismissal statute (Code Civ. Proc., § 581) in the context of the statewide tentative ruling system.

This case is similar to those relied upon by Gallagher in which the court concluded that allowing a voluntary dismissal would undermine a statutory scheme. In Gray v. Superior Court (1997) 52 Cal.App.4th 165 [60 Cal.Rptr.2d 428] (Gray), the court held a plaintiff could not voluntarily dismiss his partition complaint without prejudice after an evidentiary hearing before a referee in the face of an unfavorable recommendation by the referee. The court held that the trial had actually commenced where evidence had been presented to the referee in a partition proceeding, even though the referee’s findings were advisory only. (Id. at p. 173.) Analyzing the cases refusing to allow a plaintiff to dismiss an action as of right under Civil Procedure section 581, the Gray court observed that they were of two types: “Those in which allowing a dismissal would frustrate a statutory scheme, and those in which courts interpret ‘trial’ so broadly as to include certain proceedings at the stages of pleading or discovery.” (Gray, at p. 172.) Gray concluded that allowing a voluntary dismissal after an evidentiary hearing before a referee “denigrates the partition statutes” and circumvents that statutory scheme. (Id. at p. 173.)

The Gray court reasoned that: “The thread running through all these cases seems to be one of fairness: Once the parties commence putting forth the facts of their case before some sort of fact finder, such as an arbitrator, or at the pretrial stage a ruling is made on an issue of law or on admitted facts which effectively disposes of the plaintiff’s case against him, it is unfair— and perhaps a mockery of the system—to allow the plaintiff to dismiss his complaint and refile. While our system is adversary and grounded on vigorous disputation, it is also dedicated to justice and grounded on the fundamental fairness of its proceedings, [¶] The thread of fairness is twisted out of true by the facts of this case. Here the parties spent two days litigating their case with seven witnesses. The referee made detailed recommendations of factual findings to the court. The referee was the factfinding arm of the court. Doubtless had real party prevailed before the referee, he would not have dismissed his complaint. To allow real party to dismiss in the wake of an unfavorable referee’s recommendation would work an injustice. Trial had ‘actually commenced’ within the meaning of [Code of Civil Procedure] section 581 and within the policies of fairness in the cases set forth above. Moreover, a dismissal under [Code of Civil Procedure] section 581 denigrates the partition statutes, which provide that a party dissatisfied with a referee’s report may move that it be modified or set aside, and that the court may order a new report or appoint a new referee. ([Code Civ. Proc.,] § 873.290.) A dismissal circumvents this statutory scheme.” (Id. at p. 173.)

Mary Morgan, Inc. v. Melzark, supra, 49 Cal.App.4th 765, is another case in which the appellate court held that a plaintiff could not dismiss a complaint where the defendant had met its initial burden of entitlement to summary judgment, the hearing had begun and the plaintiff had been granted a continuance to obtain new evidence to meet its counter burden. (Id. at pp. 767, 770-772.) The court concluded that in such circumstances a voluntary dismissal would “eviscerate the summary judgment procedure.” (Id. at p. 771.) Similarly, in Hartbrodt v. Burke, supra, 42 Cal.App.4th 168, the court held a plaintiff could not defeat a defendant’s motion for a terminating discovery sanction by a voluntary dismissal filed just before the sanction hearing, as such would undermine the discovery statutes. (Id. at p. 175.)

As Weil and Brown caution, “Allowing plaintiff to dismiss after learning of an adverse tentative ruling seems contrary to policies noted in Wells, supra. It would permit a plaintiff ‘who was led to suppose a decision would be adverse to him to prevent such decision and begin anew, thus subjecting the defendant to announcing and continuous litigation.’ Moreover, it would waste ‘the time and money of the people in a fruitless proceeding in the courts . . .’ [Wells v. Marina City Properties, Inc., supra, 29 C3d at 785 . . . .]” (Weil & Brown, supra, at [¶] 11:25.3, p. 11-12.) This is precisely what occurred here. As was the court in Gray, we are persuaded that the “thread of fairness is twisted out of true by the facts of this case.” (Gray, supra, 52 Cal.App.4th at p. 173.)

Moreover, had the tentative ruling become final, and the action dismissed with prejudice as to Gallagher, he would have been entitled to mandatory indemnity under Corporations Code section 317, subdivision (d). Respondents have not argued otherwise. If the corporate agent accused of wrongdoing wins a judgment on the merits in defense of the action, indemnification is mandatory. Corporations Code section 317, subdivision (d) provides: “To the extent that an agent of a corporation has been successful on the merits in defense of any proceeding referred to in subdivision (b) or (c) or in defense of any claim, issue, or matter therein, the agent shall be indemnified against expenses actually and reasonably incurred by the agent in connection therewith.” (See also Friedman, Cal. Practice Guide: Corporations (The Rutter Group 2001) ¶ 6:439, p. 6-94.2 (hereafter Friedman).)

Indemnification is mandatory only where the actual merits of the defense have been judicially determined. (American National Bank & Trust Co. v. Schigur (1978) 83 Cal.App.3d 790, 793 [148 Cal.Rptr. 116]; accord, Wilshire-Doheny Associates, Ltd. v. Shapiro (2000) 83 Cal.App.4th 1380, 1391 [100 Cal.Rptr.2d 478] (Wilshire-Doheny); Friedman, supra, ¶ 6:441, p. 6-94.3.) However, “[Corporations Code] [s]ection 317, subdivision (d), by its terms, requires only a showing that the agent has been ‘successful on the merits in defense of [the] proceeding.’ This is a showing that ‘the disposition reflects the opinion of the court or the prosecuting party that the action would not succeed.’ [Citation.]” (Wilshire-Doheny, supra, at p. 1391.) The court need not determine that the agent is actually innocent of the alleged misconduct, but only that the agent is not liable.

Dismissal with prejudice of plaintiff’s action against Gallagher would have entitled him to mandatory indemnity from Groth Bros.

We conclude that in these circumstances, where no opposition to a pending demurrer has been filed, where the court has made a tentative ruling against the plaintiff sustaining the demurrer without leave to amend, and where the allowance of a voluntary dismissal without prejudice during the time between issuance of the tentative ruling and the ruling becoming final would make a mockery of the tentative ruling procedure and would also frustrate the statutory scheme for indemnification of corporate officers, the court erred in concluding that it lacked jurisdiction to vacate the voluntary dismissal and in failing to grant the demurrer dismissing the action as to Gallagher with prejudice. In these circumstances, we shall reverse the order of the lower court denying mandatory indemnity to Gallagher.

Conclusion

We reverse the order denying Gallagher’s application for indemnity. We remand to the trial court, with instructions to vacate the voluntary dismissal of the first amended complaint as to Gallagher; to enter a judgment sustaining the demurrer without leave to amend as to Gallagher only; and to enter a judgment dismissing the action on the amended complaint as to Gallagher. We further instruct the trial court to order Groth Bros, to indemnify Gallagher for his legal fees and costs incurred in defense of the first amended complaint.

Gallagher is awarded his costs on this appeal.

Lambden, J., and Ruvolo, J., concurred. 
      
       In addition to other defendants, Gallagher’s mother Irene Walkenshaw was also sued. She and Gallagher answered together and together demurred to the first amended complaint. However, she did not seek indemnity and is not a party to this appeal.
     
      
       Pursuant to Code of Civil Procedure section 472, the plaintiff has the right to amend a complaint once as of course, “after demurrer and before the trial of the issue of law thereon . . . .” (Code Civ. Proc., § 472.) The court had enforced a rule that no second amended complaints could be filed without court order. The trial court indicated that “there might be something to that” in reference to plaintiff’s counsel’s argument “that the plaintiff may in fact have the right to file a Second Amended Complaint because the court required the filing of a first. . . .” Because the court was satisfied with the second amended complaint proposed by plaintiff against other defendants following his voluntary dismissal of Gallagher, this question was not pursued.
     
      
       The record before us contains no order denying or otherwise acting upon the demurrers or Gallagher’s request to vacate the voluntary dismissal.
     
      
       “To the extent that an agent of a corporation has been successful on the merits in defense of any proceeding referred to in subdivision (b) or (c) or in defense of any claim, issue, or matter therein, the agent shall be indemnified against expenses actually and reasonably incurred by the agent in connection therewith.” (Corp. Code, § 317, subd. (d).)
     
      
       “A plaintiff may dismiss his or her complaint, or any cause of action asserted in it, in its entirety, or as to any defendant or defendants, with or without prejudice prior to the actual commencement of trial.” (Code Civ. Proc., § 581, subd. (c).)
     
      
       The statute before the Wells court provided in relevant part:
      “An action may be dismissed in the following cases: [¶] 1. By plaintiff, by written request to the clerk, ... at any time before the actual commencement of trial. ... A trial shall be deemed to be actually commenced at the beginning of the opening statement of the plaintiff or his counsel, and if there shall be no opening statement, then at the time of the administering of the oath or affirmation to the first witness, or the introduction of any evidence. [¶] ... [¶] 3. By the court, . . . when, after a demurrer to the complaint has been sustained with leave to amend, the plaintiff fails to amend it within the time allowed by the court, and either party moves for such dismissal.” (Stats. 1974, ch. 1369, § 4, pp. 2966-2967; Wells, supra, 29 Cal.3d at p. 784.)
     
      
       Even the Court of Appeal decision in Datner, which focused upon an in-chambers tentative opinion, was rendered in 1983, before statewide adoption and formalization of the tentative ruling procedure.
     