So are you saying that I can claim the lent money back against rental income
No I'm not saying that and, to be clear, your loan is not deductible against your rental income from after the transfer of ownership of the flat to you or the rental income of her estate/personal representative during the period between her death and that transfer to you,
But with regard to rental income arising before her death, was the maintenance (not capital improvements) part of the expenditure incurred after she went moved out of the flat into sheltered accommodation in preparation for the flat being rented out deducted on her tax return from her rental income? It not an amended return could be submitted so to re-claim part of the tax she paid. But it could be that her pension and rental/other income were in total less than her age adjusted personal allowance in which case no income tax was payable by her and so there is no point in submitting an amended tax return for her to include such costs against her rental income. If her rental income has been reported to HMRC than, depending on its value, overdue returns may be required - however reporting rental income and overdue self-assessments are not my areas.
Concerning your capital/loan, the accounting analysis is: You lent Gran the money, she died owing that loan to you (but her death estate you say has insufficient cash to pay you back so you write off that debt) and you inherit the flat at its market value at the date of her death (which value presumably reflects part, if not all, of the pre-death expenditure you financed to make the flat rentable).