xa_sharma you can disabled Flags, then select "Uninstall" on the extension page. This will permanently destroy all the data of the extension (effectively, all active flags), except settings and permissions.
If that doesn't help can you share your php flarum info output and maybe a view of the flags table in the database?
I'm really not sure what it could be. The error might indicate a broken post-discussion relationship, but posts shouldn't be able to have a null discussion relationship. It could also be an extension that affects the flag dropdown or the discussion model. You can try disabling all extensions to see if the issue goes away.