SSan Francisco Mayor Edwin Lee and the city's legislators are nearing an agreement on a compromise plan to impose new restrictions on health reimbursement arrangements, potentially setting the stage for a new legal battle involving the city's controversial healthcare spending law.