In the event of suit against such third party:
(a)
If the action is prosecuted by the employer alone, the court shall first order paid from any judgment for damages recovered the reasonable litigation expenses incurred in preparation and prosecution of such action, together with a reasonable attorney’s fee which shall be based solely upon the services rendered by the employer’s attorney in effecting recovery both for the benefit of the employer and the employee. After the payment of such expenses and attorney’s fees, the court shall apply out of the amount of such judgment an amount sufficient to reimburse the employer for the amount of his expenditure for compensation together with any amounts to which he may be entitled as special damages under Section 3852 and shall order any excess paid to the injured employee or other person entitled thereto.
(b)
If the action is prosecuted by the employee alone, the court shall first order paid from any judgment for damages recovered the reasonable litigation expenses incurred in preparation and prosecution of such action, together with a reasonable attorney’s fee which shall be based solely upon the services rendered by the employee’s attorney in effecting recovery both for the benefit of the employee and the employer. After the payment of such expenses and attorney’s fee the court shall, on application of the employer, allow as a first lien against the amount of such judgment for damages, the amount of the employer’s expenditure for compensation together with any amounts to which he may be entitled as special damages under Section 3852.
(c)
If the action is prosecuted both by the employee and the employer, in a single action or in consolidated actions, and they are represented by the same agreed attorney or by separate attorneys, the court shall first order paid from any judgment for damages recovered, the reasonable litigation expenses incurred in preparation and prosecution of such action or actions, together with reasonable attorneys’ fees based solely on the services rendered for the benefit of both parties where they are represented by the same attorney, and where they are represented by separate attorneys, based solely upon the service rendered in each instance by the attorney in effecting recovery for the benefit of the party represented. After the payment of such expenses and attorneys’ fees the court shall apply out of the amount of such judgment for damages an amount sufficient to reimburse the employer for the amount of his expenditures for compensation together with any other amounts to which he may be entitled as special damages under Section 3852.
(d)
The amount of reasonable litigation expenses and the amount of attorneys’ fees under subdivisions (a), (b), and (c) of this section shall be fixed by the court. Where the employer and employee are represented by separate attorneys they may propose to the court, for its consideration and determination, the amount and division of such expenses and fees.