Almost good imo, I've made some adjustments (split, various nits cleanup) in https://gitlab.winehq.org/rbernon/wine/-/commits/tmp-2875, if you don't mind having a look and updating the MR with these changes.
I used `(nid->dwInfoFlags & NIIF_ICONMASK) == NIIF_USER` instead, but like I said above I'm not sure about it so feel free to change it back.