The test is the best interests of the child and the presumption is that contact with both parents is in those interests. When one parent has problems , however, substance abuse or criminality to name a few, the Courts will shy away from awarding joint custody. Often the solution is to let the miscreant parent have supervised visitation every week or so until he/she demonstrates that he can be trusted. There are agencies that supervise these visits and report to the courts. You should have a lawyer for custody matters and he will probably suggest supervised visitation unless you are already prepared to give more.
Sign up to receive a 5-part series of useful information and advice about child custody law.