If an action is pending against the decedent at the time of the decedent's death, the plaintiff shall, within four months after appointment of the personal representative, serve on the personal representative a petition to have the personal representative substituted as defendant in the action. Upon hearing on the petition, the personal representative shall be substituted, unless, at or before the hearing, the claim of the plaintiff, together with costs, is allowed.