Gretzky had a legal contract that paid him $8M per year for services rendered. You can argue all you want as to the stupidity of him getting that amount of money or if, as you say, did he deserve it ... but the fact is he is owed that money.
It would be hilarious to see Gretzky sue the NHL to get his money. Another positive effort on the behalf of Bettman.
He's at least owned the back pay before he resigned. If he did voluntarily resign as appears to be the case then it's unlikely he's owed anything for the unfulfilled portion of the contract.
Since Gretzky was listed as a creditor in the bankruptcy it's doubtful the NHL owes him anything, though I'm sure one can hire lawyers to craft just about any type of argument.
IMO it truly was dirty what Moyes did with Gretzky's contract and I'm still surprised the court didn't hold Moyes responsible for TGO's backpay. For those that didn't follow the saga: what happened is TGO's employment contract was a personal services contract directly with Moyes, not with the team. Shortly before filing bankruptcy Moyes signed a contract "transferring" the obligation from himself personally to the team ownership organization without TGO's knowledge. Moyes signed this new contract twice, once in his capacity as Jerry Moyes the person and once in his capacity as president of the ownership organization.
TGO's contract contained no allowances for transfership of either side's obligations. Imagine you had a contract with someone to do work for them. Come payday they tell you that it's some other party that's responsible for paying you, even though the contract you signed has no allowance for that. Oh and by the way that other party doesn't have any money, so you're SOL, even though Jerry Moyes could afford to pay TGO.