Out of any recovery had in an action under this chapter, the expenses incurred in the action by the freeholders, including payments made or to be made for legal services in an amount to be approved by the court, shall be first deducted and the balance thereupon be paid into the treasury of the municipality or school district in whose behalf the action is brought.
N.J.S. § 2A:49-3