Hello from JustAnswer.
Alcohol, itself, actually clears from the system quickly, so the urine test that is most often done is for a metabolite of alcohol, called ethyl glycoronide, or EtG. The urine test for EtG is touted as a test that can detect alcohol for 80 hours after the last drink, but this is really only the maximum period of detection. Actually, the vast majority of people will only have detectable levels of EtG for 24-48 hours after the last drink, and it is only a small minority in whom it can be detected in the 72-80 hour window.
Liver disease will slow the metabolism of alcohol, but if the only indication is an increase in liver enzymes, it typically will not significantly affect the duration of detection of EtG. In people with more severe liver dysfunction, such as cirrhosis, then there may be some people in whom the EtG can be detected for up to 7 days.
So, if you know when the testing will be done, it is generally recommended that alcohol consumption stop at least 80 hours before the test, which is 3 days and 8 hours. Someone with more severe liver dysfunction would do better to stop alcohol consumption 7 days before testing.
If I can provide any additional information, please let me know.