You may be able to recover some if not all of the expenses. You may need the assistance of an attorney in PA to get this accomplished. Your first step is to find out the case number of the probate and learn who is administering the matter. An attorney can help you do this and can advise you if the $40,000 is sufficiently large to be addressed by a probate court in PA. After you obtain that information you will want to file a claim with the estate. Procedures vary from state to state so an attorney familiar with PA law would be helpful to you. Once the court is made aware of the claim they will not allow the probate to be closed until it is adequately provided for. If the estate is insufficient to pay all of its debts then there will likely be some sort of a pro rated distribution among the claimants based on their priorities. But if you do not get a valid claim submitted it cannot be considered and generally speaking there is a limited time for claimants to submit their claims for payment. You should really seek help from an attorney who knows the proper procedures in PA.
The ideas and opinions expressed in this comment are generalities only and not based upon a thorough analysis of your situation or the law that might apply to you. As such they are intended to be general guidance and not legal advice. Use this information to assist in your analysis as to what you want to ask an attorney when seeking legal advice, Nothing stated herein shall be deemed to create an attorney-client relationship with you nor legal advise for you to use.