I'm trying to make a pipeline that removes users with a privacy distance from another user's query

It’s a privacy setting that I’m trying to create. In it, the $geoNear calculates a distance called distance_calculated which returns a number. that number is compared to the users nonpreferences.distance.min & nonpreferences.distance.max to create a privacy circle that prevents them from turning up in another user’s query. I’ve added a small value for edge cases that adds 0.001 to the distance_calculated for users who might want privacy from other users in their immediate area.

my issue is that even though a users distance.min might be zero, they are still turning up in another user’s query. How do I prevent this?

const pipeline = [
      {
        $geoNear: {
          near: { type: "Point", coordinates: [longitude, latitude] },
          distanceField: "dist_calculated",
          spherical: true,
          query: {
            gender_identity: gender,
            age: { $gte: age_min, $lte: age_max },
          },
          minDistance: min_distance,
          maxDistance: max_distance,
        },
      },
      {
        $addFields: {
          dist_calculated: {
            $cond: {
              if: { $eq: ["$dist_calculated", 0] },
              then: 0.0001,
              else: "$dist_calculated",
            },
          },
        },
      },
      {
        $match: {
          $expr: {
            $or: [
              { $lt: [
                 "dist_calculated",{$ifNull: ["$nonpreferences.distance.min", Infinity]} ] },
              { $gt: ["dist_calculated", {$ifNull: ["$nonpreferences.distance.max", -Infinity] }] }
            ],
          },
        },
      },
    ];