It is helpful to contemplate unwholesome mind-states in relation to the threefold division of the eightfold path. Each layer corresponds to one of the three divisions.
THE LAYER OF LATENT TENDENCY - WISDOM DIVISION
In this layer, the seeds of the unwholesome states called latent tendencies lie dormant within the mind, ready to manifest when the right causes and conditions arise. For example, if we are in a peaceful environment, with no disturbance to our sense of self, our latent tendencies remain dormant. However, if our peace is disrupted, our sense of self may be threatened, and unwholesome mind-states may manifest.
The Wisdom Division of the Eightfold Path illuminates and transforms latent tendencies at the roots. These unwholesome mind-states are ultimately rooted in delusion/ignorance. Ignorance is the field that pervasively distorts our views, thinking, actions, and all other activities. When we cultivate Wise View and Wise Thinking, all other path factors become unified and eventually purify the mind of latent unwholesome tendencies.
THE LAYER OF MANIFESTATION - MENTAL CULTIVATION
In this layer, the latent tendencies become activated through a stimulus, manifesting as unwholesome thoughts, feelings, intentions, or other mental volitions.
The Mental Cultivation Division of the Eightfold Path removes unwholesome manifestations that have arisen in the mind and protects the integrity of current mind-states. When right energy, mindfulness, and concentration are active, the mind catches the proliferation of mental unwholesomeness and prevents them from manifesting into the layer of transgression.
THE LAYER OF TRANSGRESSION - SILA TRAINING
In this layer, the unwholesome manifestations lead to harmful actions of body or speech.
The Moral (Sila) Training Division of the Eightfold Path protects against the proliferation of unwholesome manifestations of speech and activities that have already arisen.