So here is the final expression.
It gets the distance at any given time and the maximum distance in the whole timeline
pA = thisComp.layer("A").transform.position;
pB = thisComp.layer("B").transform.position;
NowDist = length(pA, pB);
MaxDist = 0;
t =0;
while(t < thisComp.duration){
MaxDist = Math.max(MaxDist,length(pA.valueAtTime(t),pB.valueAtTime(t)));
t += thisComp.frameDuration;
}
scala = MaxDist/NowDist*100;
[scala, scala];