State officials have agreed as many as 40,000 defendants are entitled to be reimbursed after their convictions were vacated, the bulk in 2017 and 2018, by the Supreme Judicial Court due to rampant misconduct at two state labs that tested evidence for their cases.