There is no such rule. ANY clauses will work:
If CLAUSE1, then CLAUSE 2. ("then" is sometimes omitted)
A clause is anything of the form SUBJECT + VERB that stands on its own just like a sentence. Your sentence works because it contains two clauses. The present participle has absolutely nothing to do with it. In your sentence,
CLAUSE1 = "I am ... to go". (subject ="I", verb="am"),
CLAUSE2 = "There is ... on it". (subject="There", verb="is").
If you eliminate everything else, it still works:
"If I am, then there is"
is a good sentence.
In your sentence, the phrase "just getting a cup of coffee to go" is an adjective phrase (a "subjective complement") that modifies the subject of the sentence, "I"). You can replace this adjective phrase with ANY adjective and you will still have a good sentence:
"If I am happy, there's no need ..."