Assuming that K is related to X, W, Z (no conditional independence: P(K, D) = P(K | D) * P(D)
), then it should not be a problem:
P(Y, K | D) = P(Y | K, D) * P(K, D) = P(Y | K, D) * P(K | D) * P(D)
where the first and second terms in the right-most side of the equation are estimated by your model and K is a hidden variable.
If the K variable cannot be predicted from the data (i.e. P(K, D) = P(K) * P(D)
or equivalently P(K | D) = P(K)
) then your model will be missing a variable. It does not mean that it will not manage to predict anything good but rather that it does not have all the information needed to predict your target variable correctly.