How to fill ngon with quads?
Bisect with boundary edges.
Based on the rectangular nature of the corners of given mesh.

Sample result, far from optimized as some edges above could be dissolved.
A script to create a plane from all the boundary edges. The plane coord is edge center, the plane normal is nominated up direction (Z axis) crossed with edge direction.
Script, run in edit mode.  Note in hindsight should limit this to selected ngons, and edges.  For test sake make the ngon its own object, place in edit mode.
import bpy
import bmesh
from mathutils import Vector

ob = bpy.context.edit_object
me = ob.data

bm = bmesh.from_edit_mesh(me)

up = Vector((0, 0, 1))
def as_plane(e):
    return (
        (e.verts[0].co + e.verts[1].co) / 2,
        up.cross(e.verts[1].co - e.verts[0].co).normalized(),
        )
        
    
planes = [as_plane(e) for e in bm.edges if e.is_boundary]

while planes:
    plane_co,  plane_no = planes.pop()
    if plane_no.length &lt; 1e-4:
        continue
    bmesh.ops.bisect_plane(
            bm,
            geom=bm.edges[:] + bm.faces[:],
            plane_co=plane_co,
            plane_no=plane_no,
            )
            
bmesh.ops.remove_doubles(
        bm,
        dist=1e-4,
        )

bmesh.update_edit_mesh(me)