Although this is kind of an old post, I came accross a use-case, where I would need to cancel both an approval task and the specific flow in which it was initiated.
The datasource used is a couple of Sharepoint lists, but it should work with any other datasource.
Use-case:
1. User submits request via PowerApps
2. Approval flow kicks in
3. User needs to make a modification to their submitted request via PowerApps (only able to do so if no approval was provided prior to the modification)
4. New approval flow kicks in, as request needs to be "re-approved"
What I did was building two flows for this:
1. The actual approval flow
2. A second flow, which cancels both the approval and the flow as well, then initiates a new approval
Approval flow:
1. Monitoring for new items in a Sharepoint list.
2. Compose and Parse JSON steps are saving the flow name and run ID into the Sharepoint list with Update Item.
3. Using Start an approval and NOT the Start and wait for approval, which makes it hard for you to obtain the approval ID. Start an approval creates the approval and allows you to run further actions within the flow without it being stalled until approval is completed. You can insert a new Update Item step, where you obtain the approval ID and save it into a Sharepoint list, then insert a Wait for an approval step.
At this point you have all the information to be able to cancel an approval task and/or a flow run.
Second flow:
1. Trigger can be multiple, but I used a separate Sharepoint list to store modification requests, so using the When a new item is created trigger.
2. Get Items collects the flow run ID.
3. Cancel Flow Run (not a premium connector) is added after this, where you define the flow run ID as a dynamic content from the Get Items step, which stops my flow in which the approval runs, so it doesn't get orphaned.
4. Invoke HTTP request (this is a premium connector though) is being ran after this, with the proper Headers, Request URL and DELETE method (don't worry, it won't actually delete anything), it cancels the actual approval, disallowing approvers to react to 2 approvals for the same item. You will be able to use the saved tenant name and approval ID as dynamic contents within your URL.
5. After these steps, a new approval is initiated, which will modify the original item's status according to approval outcome.