Solved my own problem. For those who are interested you you will need to use toComp(). This converts the layer coordinates to the camera space coordinates. Then, given any z depth, the viewport position matches the pixel dimensions in your comp size. So, for example, if you are using a 1920×1080 comp, the x value of the left edge of the screen is always 0 and the y value of the right is always 1920, no matter what the z value is. I added a variable in my code to allow for objects with an anchor point slightly out of the viewport to still be visible.
ext = .2;
width = thisComp.width;
height = thisComp.height;
minWidth = 0 - (width * .2);
maxWidth = width + (width * .2);
minHeight = 0 - (height * .2);
maxHeight = height + (height * .2);
z = Math.ceil(Math.abs(toComp([1,1,1])[2]));
x = Math.ceil(toComp([1,1,1])[0]);
y = Math.ceil(toComp([1,1,1])[1]);
isInViewport = (x > minWidth && x < maxWidth) && (y > minHeight && y < maxHeight);
isInFrontOfCamera = toCompVec([0, 0, 1])[2] > 0;
if (isInFrontOfCamera && isInViewport ) {
this.opacity = 100;
} else {
this.opacity = 0
}