Subordinate clauses with «det» vs «det som»

I understand in which cases you use «hvem» vs «hvem som» in subordinate clauses: when the subordinate clause lacks the subject, you add the «som» (for exemple «Jeg vet hvem som kommer til festen» vs «Jeg vet hvem du er», «du» being the subject while the former lacks subject).

But when it comes to «det» vs «det som», I can't quite understand in which cases the «som» is mandatory. For example, in the sentence «Jeg liker det som du sa», as far as I understand, the «som» is optional and could just be written «Jeg liker det du sa». (Correct me if this is wrong.)

So in which cases is the «som» required? Are there any cases in which it is incorrect to put «som» and should write «det» alone? I would appreciate some rules on this. Bonus points for «hva» vs «hva som».

På forhånd takk!