thatThat in this case is optional, so both are grammatically correct. Depending on the communicative situation you may slightly decide for one over the other. In normal speech situations I'd probably use the first one but contracted "I'mI'm sorry it took so long"long.