@rbernon I just pushed the new tests and a revised fix that refactors the code as you suggested. I hope that it is clear now what exactly is being fixed. Would you be willing to review the two new patches?
By the way, I was surprised to find that in the cases where wglShareLists succeeds on AMD and fails on NVIDIA, the AMD testbot crashes later in wglDestroyContext. The same tests pass without crashing on my own Windows 10 desktop that has an RX 5500 XT. My opinion remains unchanged that having Wine's wglShareLists succeed (and Wine's wglDestroyContext not crash) is the right thing to do.