A Catholic is never permitted to receive Holy Communion in the state of mortal sin.
A person in this state must receive the sacrament of Penance. A Catholic is never permitted to receive Holy Communion while under the penalty of excommunication until it is lifted by competent authority, which includes priest, bishop, or pope, depending upon the severity or nature of the excommunication.
Catholics living in a perpetual sinful state should also not receive Holy Communion until it is rectified. For example, a person who is married, divorced, and remarried outside the Catholic Church without an annulment is living in a perpetual state of mortal sin. The only exception to the rule is if the remarried couples live as brother and sister and not in a conjugal union, until the annulment is procured and the marriage is convalidated in the Catholic Church.
Another example is if a baptized Catholic marries outside the Church without dispensation or permission obtained from the bishop, then the marriage is not recognized by the Church and the couple must refrain from reception of Holy Communion until this is ratified.
A person who is dealing with a habitual sin in the sacrament of Penance might not be in the state of mortal sin because the freedom of the will has been reduced.