It’s tricky, and a little complicated, but this example might help. It assumes that 4 text layers are participating and that they are layers 1 through 4 in your layer stack. They’ll be positioned in y in the order of their layer index (layer 1 on top), with the center of the visible layers positioned and mid y point in the comp. It should adjust for any layers that have no text.
margin = 20;
above = 0;
below = 0;
r = sourceRectAtTime(time);
myH = r.height;
for (i = 1; i <= 4; i++){
if (i == index) continue; // skip own layer
h = thisComp.layer(i).sourceRectAtTime(time).height;
if (i < index){
if (h > 0) above += h + margin;
}else{
if (h > 0) below += margin + h;
}
}
tot = above + myH + below;
mid = tot/2;
myMid = above + myH/2;
deltaY = mid - myMid;
currentY = value[1] + r.top +r.height/2;
targetY = thisComp.height/2 - deltaY;
value + [0,targetY - currentY]