Yea, by current rule that's a valid goal because the player whose hand it hit didn't score the goal immediately after.
Technically even if the ball had gone off his hand and then was immediately headed in by another West Ham player it would also count since he didn't score the goal himself.
It's why the Rashford goal was ruled out (because he scored the goal himself in the same movement/attacking play as the accidental handball) but the Antonio one counted because he took a shot, it hit the post, and then he put in the rebound so it wasn't "immediate"