I guess you’d have to move the part that calculates moveAmt into the section after n is calculated, like this (not tested):
m = marker;
n = 0;
moveTime = .2;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (time < m.key(n).time) n--;
}
if (n > 0){
innerMessageHeight = comp("Messages_Comp").layer(index+n).sourceRectAtTime().height+20;
moveAmt = innerMessageHeight;
t = time - m.key(n).time;
value + [-(n-1)*moveAmt-ease(t,0,moveTime,0,moveAmt)];
}else
value
Dan