This is the most straightforward solution I found if we want to consider
that task a bug. It is still a hack and some things won't work, but this
should make the most common use cases work as they should.
The other option would be to consider this a known issue and decide a
proper solution in T76659. When implementing the new vertex paint mode
this same issue is going to appear if the implementation is similar to
the current sculpt mask, but in that case hacks like this won't be