As has been said, Lewis was an Anglican, and Anglicans generally do accept divorce at least in the case of adultery, which Mr Gresham had been committing.
Unfortunately I don’t have the texts with me now, but I’ve read Lewis’s collected letters, and it looks as if Mr Gresham had also been married before he married Joy, and that wife was still alive - so in other words, we as Catholics would say that Gresham’s marriage to Joy was invalid, so she would have been free to marry Lewis. I think Lewis as an Anglican was not 100% convinced if adultery was grounds for divorce and remarriage, or whether the Catholic position was true - finding this out made him happy that no matter what, it would be “okay” to marry her. So I think he would have been convinced that marrying her was all right to do.
Interestingly, Lewis and Joy were first married in a civil ceremony, because Joy’s visa had expired and otherwise she would be forced to return to the US. It was purely a marriage of “convenience”, and they didn’t intend for it to be anything else - their relationship had been platonic up until then. It was only when Joy was diagnosed with cancer, and the two of them had fallen in love, that Lewis had an Anglican priest marry them “in the eyes of God”. They took their vows again in her hospital room, and afterwards she was discharged and allowed to go home, where she moved in with Lewis - her cancer would go into remission and she would live another three years instead of the expected weeks or months.