I am running a logistic regression model and I know how to test the linearity assumption of continuous variables with the log odds. However, I am not sure if this has to be checked in the presence of an interaction term. For example if I model a continuous and categorical variable as well as their interaction, and the continuous variable fails the linearity assumption, it should still be okay to include the interaction term, is this correct? Or do I need to check linearity of the continuous variable at each level of the categorical variable?

Say for example a continuous 'time' variable is not linearly related with the log odds, but at different levels (for example 'gender') this interaction is significant in the full model. It would seem that excluding time, and thus the interaction term because it violates the linearity assumption, would not be good practice and result in a poor model.

I'd appreciate a potential reference if someone knows the answer.

Thanks!