def METHOD_NAME(
    lock: bool = False,
) -> Optional[model.PoolCategory]:
    query = db.session.query(model.PoolCategory).filter(
        model.PoolCategory.default
    )
    if lock:
        query = query.with_for_update()
    category = query.first()
    # if for some reason (e.g. as a result of migration) there's no default
    # category, get the first record available.
    if not category:
        query = db.session.query(model.PoolCategory).order_by(
            model.PoolCategory.pool_category_id.asc()
        )
        if lock:
            query = query.with_for_update()
        category = query.first()
    return category