Take a look at the original sentence again:
Mike has terrible eating habits when he
opened his lunch bag, we saw a bag of potato chips, two candy bars, cellophane-wrapped
cupcakes, and a carton of chocolate milk.
You chose to fix it the correct way:
Mike has terrible eating habits; when he
opened his lunch bag, we saw a bag of potato chips, two candy bars, cellophane-wrapped
cupcakes, and a carton of chocolate milk.
Mike has terrible eating habits is a complete sentence. When he opened his lunch bag, we saw ... begins the second complete sentence. You are always correct when you use a semicolon between the two complete sentences that create the comma splice.